BobLoblaws
Programmer
Let's say there are 4 tables. Customer, Product, Invoice, and Returns.
Here is my SQL query so far. It works fine.
However, I want to do a SUM on Returns.qty_returned where the REASON = 1 and 2.
But I can't put this in the WHERE clause b/c it will exclude the other records. I think the query should work like this.
but it doesn't work...
Any ideas
Here is my SQL query so far. It works fine.
Code:
SELECT
Customers.CustomerID,
Customers.Long_desc AS 'Description',
Products.ProductID,
Products.p_Desc AS 'Description',
SUM (Invoice.qty_ordered - Returns.qty_returned) AS 'QTY Sold',
FROM
Customers, Products, Invoice, Returns
... and so on
However, I want to do a SUM on Returns.qty_returned where the REASON = 1 and 2.
But I can't put this in the WHERE clause b/c it will exclude the other records. I think the query should work like this.
Code:
SELECT
Customers.CustomerID,
Customers.Long_desc AS 'Description',
Products.ProductID,
Products.p_Desc AS 'Description',
SUM (Invc.ordered - Returns.returned) AS 'QTY Sold',
SUM (Returns.returned) WHERE REASON =1 AS 'Bent',
SUM (Returns.returned) WHERE REASON =2 AS 'Cut'
FROM
Customers, Products, Invc, Returns
... and so on
but it doesn't work...
Any ideas