i have a DB with all transactions of my online webshop, and im trying to make a query to print out a simple financial statement.
it will be printed in a table like this:
<th>month</th>
<th>number of sales</th>
<th>money in</th>
<th>money out</th>
<th>result</th>
the query that fails with: #1111 - Invalid use of group function
SELECT
month(transaction_date) as month,
count(incoming_amount > '0') as number_of_sales,
sum(incoming_amount / 1.25) as money_in,
sum(outgoing_amount) as money_out,
sum((incoming_amount / 1.25) - sum(outgoing_amount)) as result
FROM myDB WHERE year(timestamp) = '2011' order by id desc");
Can anyone point me in the right direction?
myDB?