How can I group my results in a query such as this:
SELECT (
SELECT SUM(wky) FROM table
WHERE Earnings_Date BETWEEN '2011-08-14' AND '2011-08-16'
) +
(SELECT SUM(earnings) FROM table
WHERE Earnings_Date BETWEEN '2011-08-14' AND '2011-08-16') / .75
The above query returns wky+(earnings/.75) for all the sites (each site has a wky and earnings number for different dates. Where would I put a group by in the above query? I would like my results to be grouped by site_id, since the above query just returns the sum of the earnings of all of them.
Thanks!
Your data comes from the same table for both queries, so you can combine them.