Reputation: 688
I have two tables
Table verkoper
Table bestellingen
My Query:
SELECT v.naam,
SUM(COUNT(b.status) * 1.50)
FROM verkoper AS v INNER JOIN
bestellingen AS b ON b.verkoper = v.id
WHERE b.status = 'retour'
GROUP BY b.verkoper
It gives me the error #1111 - Invalid use of group function
Anyone an idea?
Upvotes: 0
Views: 66
Reputation: 1269443
I think this might be what you want:
SELECT v.naam, COUNT(*)*1.50
FROM verkoper v INNER JOIN
bestellingen b
ON b.verkoper = v.id
WHERE b.status = 'retour'
GROUP BY v.naam;
Notes:
GROUP BY
keys should match the unaggregated columns in the query.COUNT(*)
or COUNT(1)
. This is simpler to type.COUNT()
inside SUM()
.Upvotes: 2