Class List No:
INSTRUCTIONS TO CANDIDATES
FACULTY: INFORMATION AND COMMUNICATION
Write all your answers on the test TECHNOLOGY
paper OR can be done on the computer
and saved as
StudNumST.sql in the relevant folder DEPARTMENT: SOFTWARE ENGINEERING
as instructed by your lecturer
Make sure ALL Your details are included
(student no, Surname& Initials) on the
front page of your answers. DSO23AT / SFW20AT / ISY23AB/DBR311T
All answers must be in ink, no pencil
answers will be marked
No additional paper may be used or Semester Test 1
handed in, Extra paper is added at the
back of the test and must be handed in
with the test
Chapter 1 – Chapter 6
NO CALCULATORS or ELECTRONIC
DEVICES may be used
Use Clearwater Database answer all
questions
Sign the declaration before proceeding
Lecturer’s Name:
25th March 2011
OTAL: 80 Venue:
ME: 240 MINUTES
AGES: 5 (incl. cover)
PC #:
ST
EXAMINER: MA Masethe
ND
EXAMINER: C Phiri
STUDENT NUMBER:
declare that I am familiar with, and will abide
the Examination rules of Tshwane
niversity of Technology – Annexure A
SURNAME INITIALS
GNATURE %
Question 1 16
Question 2 23
Question 3 25
. .
Question 4 16 80
Question 1 [16]
1.1. Create a query that displays the inventory id with the colour and price of each item. Display the output as shown below for all
inventories will price value in the range 35.00 and 500.00. (4)
1.2. Create a query that uses the IN operator to include the list of the colours khaki, royal, and turquoise to display inventory id,
colour, price and quantity, total price which is the product between the quantity and the price, for all inventories that have a
price above R20. Use column aliases were necessarily. (9)
1.3. Write the query that will eliminate all the duplicate rows of item id and colour. (3)
Question 2 [23]
2.1 Display the ct_shipment_id, quantity, and the dates that all items have been received, and the date format as
shown in the diagram below. Inventories not yet received must display Still waiting delivery on the date received. (6)
DSO23AT / ISY23AB/DBR311T Semester Test 01 25 March 2011 1
2.2 Write the preceding SQL statement using decode function, that will test the value of the inv_id, if inv_id is 11668 then the price
get a 20% discount, and if inv_id is 11775 then discount is 10% and if the inv_id is 11795 the discount is 5%. For all other
invoices, there is no discount in the price. Display only the discounted inventories. Round the value to the nearest two decimal
points. (10)
2.3 Write and SQL statement that will produce the following output as is. Use columns aliases.
(7)
Question 3 [25]
3.1 Write an SQL statement that uses aliases to display the shipment id, inventory id, date expected, date received and calculate the
number of days the order was late from the expected date to the received date of all shipment which were late.
Your output should resemble the one below. (11)
3.2 Write a code that calculate the total types of items, the overall quantities and total price of those items per each item. Each item
has more than one type. (7)
3.3 Write an SQL statement that will produce the following output and all the aliases must be adhered to. (7)
DSO23AT / ISY23AB/DBR311T Semester Test 01 25 March 2011 2
Question 4 [16]
4.1. Write an SQL that displays the following output for all items who have quantities more than the lowest quantity of item 995,
excluding the 995 item in your output. (8)
4.2. Write an SQL that displays that all clients who has order more or equals to 3 items. (8)
DSO23AT / ISY23AB/DBR311T Semester Test 01 25 March 2011 3