is there a query which can do this? productTotal is calculated from the ReceiptSummaryTable where type = product
As for facialTotal and manicureTotal will be slightly complicated. facialTotal is calculated from ReceiptSummaryTable where type = product AND category = facial in ServicesAndProductsTable.
likewise for manicureTotal.
anyway, i'm using sql server 2000.
Last edited by sphericalx; Dec 11th, 2008 at 03:07 AM.
i'm working on a window application thus i need the result to be returned in such a way therefore i can pass it over to my window application to be shown on a datagridview.
Well, there is a way but I would first recommend dropping the summary table (you really don't need it) and adding Employees and Clients (if you don't already have those).
See attached image.
Last edited by RhinoBull; Dec 11th, 2008 at 04:02 PM.
anyway, manage to get the solution to it from someone else. thanks alot for ur help too!! ^^
for the benefits of whoever that might come across with this problem, below is the solution
Originally Posted by visakh16
SELECT RST.employeeName,
SUM(CASE WHEN SPT.type='product' THEN RRT.amt ELSE 0 END) AS productTotal,
SUM(CASE WHEN SPT.productCategory='facial' THEN RRT.amt ELSE 0 END) AS facialTotal,
SUM(CASE WHEN SPT.productCategory='manicure' THEN RRT.amt ELSE 0 END) AS manicureTotal
FROM ReceiptSummaryTable RST
INNER JOIN ReceiptRowsTable RRT
ON RRT.ReceiptID = RST.ReceiptID
INNER JOIN ServicesAndProductsTable SPT
ON SPT.productID = RRT.productID AND SPT.type = RRT.type
GROUP BY RST.employeeName