2b. View the shipments made to customer 'C001' by date
3a. Prepare a list of all items purchased by customer
'C001', show the date, the product description, the unit price,
the quantity shipped and the total value (quantity * price).
3b. Calculate the total value of all items shipped to
customer 'C001' on 23rd July 1998. The SQL standard way to write this date
is DATE '1998-07-23'
3c. Prepare a shipping statement for customer 'C001' it
should show the date, the legend 'Delivery' and the total value
of the products shipped on each day.
3d. Prepare a receipts statement for customer 'C001' it
should show the date, the notes and the amount received.
3e. Use the UNION command to prepare a full statement
for customer 'C001' - it should be laid out as follows. (Note
that the values shown below are not correct.) You may be able to
use '' or NULL for blank values - if necessary use 0.
You can reuse a useful "phrase" many times. For example the following query produces
a useful summary of incoming and outgoing money. This can be helpful in displaying
SELECT shipped.badguy AS badguy, shipped.sdate AS LineDate,
'Delivery' AS Legend, -price*quantity AS amount
FROM product JOIN shipped ON (product.id = shipped.product)
SELECT receipt.badguy, receipt.rdate,notes, amount
You can use this as a subquery in other queries. Better yet you can create a VIEW
and name the query.
4a. Issue the command to see the accoutnline, you should return the rows in date order.
4b. Create a list showing the outstanding balance for
What is wrong with this database.
There is no mechanism for recording returns. Suggest what
action should be taken when faulty goods are returned and money
The price of item P001 is to be increased. What effect will
this have on the calculated balance for customers who
previously purchased the item? Suggest how the structure of the
database should be amended to prevent this problem.
All goods must be purchased at list price. In practice
discounts may be given on an ad-hoc basis. Suggest how such
discounts might be recorded.
As it stands the data will just grow and grow. It may be
desirable to have a consolidation routine which removes old
records and leaves an outstanding balance for each customer.
This is unlikely to be worth doing for technical reasons. You
could store hundreds of years worth of data for a small company
at only a marginal cost of processing time or disk space.