joebloggs2004
New member
- Local time
- Tomorrow, 02:29
- Joined
- Oct 26, 2004
- Messages
- 6
I'm having trouble with these 2 queries:
A sorted list showing each product requested on each client stock request. Show client name, product number and quantity requested in name and then product order.
With this one (above) I just get a cartesian product. It doesn't only show clients that have ordered. Those who haven't it puts the product with 1 requested, same with clients who HAVE ordered - it puts a 1 next to products they haven't ordered.
9. A list showing product number, the quantity requested, the quantity picked and the difference between the two. For products stored in more than one location within a warehouse the quantities should be added together.
I've tried so many variations for both queries I'm just confusing myself more and more. Any help (in the next hour or so, preferably) would be appreciated. 
The other query I'm having trouble even starting is
10. A list of supervisors (staffid, surname and first name) and all of their subordinates (staffid, surname and first name).
It just doesn't make a lot of sense. The supervisors in the Employee table have nothing specified in the supervisor field. Their staffIDs are also available in the Warehouse table as a foreign key (managerID).
A sorted list showing each product requested on each client stock request. Show client name, product number and quantity requested in name and then product order.
Code:
SELECT C.clientName, RL.productNum, RL.qtyRequested
FROM CLIENT AS C, REQUEST_LIST AS RL
WHERE C.clientNum IN (SELECT clientNum FROM STOCK_REQUEST)
ORDER BY C.clientName, RL.productNum;
9. A list showing product number, the quantity requested, the quantity picked and the difference between the two. For products stored in more than one location within a warehouse the quantities should be added together.
Code:
SELECT RL.productNum, RL.qtyRequested, COUNT(PL.quantityPicked) AS [Quantity_Picked], ( RL.qtyRequested - PL.quantityPicked ) AS [Difference]
FROM REQUEST_LIST AS RL, PICKING_LIST AS PL
WHERE RL.productNum IN (SELECT productNum FROM PICKING_LIST);
GROUP BY productNum;
The other query I'm having trouble even starting is
10. A list of supervisors (staffid, surname and first name) and all of their subordinates (staffid, surname and first name).
It just doesn't make a lot of sense. The supervisors in the Employee table have nothing specified in the supervisor field. Their staffIDs are also available in the Warehouse table as a foreign key (managerID).