Quote:
Originally posted by LKBrwn_DBA
You could join the sales.invoice_no with the returned invoice_no!
|
In fact, I did that yesterday, as below:
(SELECT date(s.date_purchase ) AS "Date", st.name AS "Staff name", sum(s.total_purchase ) AS "Total Sales", 0 AS "Total returned"
FROM sales s, staff st
WHERE (s.staff_no = st.staff_no )
GROUP BY date(s.date_purchase ), st.name )
UNION
(
SELECT r.date_return AS "Date", st.name AS "Staff name", 0 AS "Total Sales", sum(r.sold_price ) AS "Total returned"
FROM returned r, staff st, sales s
WHERE ((r.invoice_no = s.invoice_no ) AND (s.staff_no = st.staff_no ))
GROUP BY r.date_return, st.name ));
But the trouble is, I can't get a listing for each day. So if there's no sales or returned goods, then there's no entry for that. Furthermore, the above UNION SQL statement separate the "Total Sales" and "Total Returned" into 2 different rows.