I have a table that has sales data in it. Sometimes there are no sales for a particular department, but I would still like that row returned in the query (just with a zero count and zero total). Any ideas?
Here is the query I currently use:
Thanks!
LJ Wilson
My personal saying - Just remember, it can always get worse, and usually will.
Here is the query I currently use:
Code:
SELECT transdepartment AS DEPT, SUM(amount * quantity) " .
"AS TOTAL, COUNT(DISTINCT(transactionid)) AS COUNT FROM " .
"tblTransactions t, tblPayments p WHERE t.transdepartment " .
"<> 'ROA' AND t.reportid= " . $reportid . " AND " .
"t.transactionnum = p.transactionnum AND p.paymentmethod " .
"<> 'Charge' AND t.storeid = '" . $storeid . "' AND " .
"t.registernum = '" . $registernum . "' GROUP BY " .
"transdepartment ORDER BY transdepartment ASC
Thanks!
LJ Wilson
My personal saying - Just remember, it can always get worse, and usually will.