Comment Re:Simple (Score 1) 1067
Bah. Invalid SQL of course. s/HAVING/WHERE as there's no GROUP BY.
Bah. Invalid SQL of course. s/HAVING/WHERE as there's no GROUP BY.
I think of it as a relational database,
SELECT A.HammerSales / B.HardwareSales AS Answer
FROM
(
SELECT Sum(Amount) AS HammerSales
FROM SALES
HAVING Item='Hammer' And MonthOfSale='201505'
) A ,
(
SELECT Sum(Amount) AS HardwareSales
FROM SALES
HAVING Department='Hardware' And MonthOfSale='201505'
) B
It will not return zero if there are no sales at all for last month. It will return an empty dataset (i.e. no data).
Always draw your curves, then plot your reading.