If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
I'm getting this error Invalid use of group function can anyone see what is wrong, I think it's in the SUM part.
Code:
<?php
SELECT
ROUND(SUM(COUNT(ordnr.ordernummer) / COUNT(off.offerte) * 100),2) AS score,
off.klant_id AS off_klant_id,
adr.klantnaam AS adr_klantnaam
FROM ordernummers AS ordnr
LEFT JOIN offertenummers AS off
ON off.offerte = ordnr.offerte_id
LEFT JOIN adressen AS adr
ON adr.id = off.klant_id
LEFT JOIN factuurnummers AS fac
ON fac.offerte_id = off.offerte
GROUP BY off_klant_id
ORDER BY score DESC
LIMIT 20
?>
Yes, I noticed it when I was closing my eyes for an minute while think it over again.
Here is an other one.
Here I want an average of 2 dates per customer_id (klant_id)
Any suggestions?
Code:
<?php
SELECT
ROUND(SUM(DATEDIFF(off.datum_offerte,ordnr.datum_order))/(COUNT(ordnr.ordernummer),1) AS aantal_dagen,
off.klant_id AS off_klant_id,
adr.klantnaam AS adr_klantnaam
FROM offertenummers AS off
LEFT JOIN adressen AS adr
ON adr.id = off.klant_id
LEFT JOIN ordernummers AS ordnr
ON ordnr.offerte_id = off.offerte
GROUP BY off_klant_id
ORDER BY fac_totaal DESC
LIMIT 20
?>