Welke records hebben meeste detail-lijnen?
sah = documentheaders
sal = documentlijnen
cus= customers
hoofding en detailijnen zijn type I invoice, D Delivery, O order.
Welke levering van welke klant heeft hoeveel details?
SELECT sah_code, cus_id, count( sah_code )
FROM sah, sal
WHERE sah_type = “D”
AND sah.sah_id = sal.sah_id
GROUP BY sah.sah_code
Welke levering van welke klant heeft veel details, in dalende volgorde?
SELECT sah_code, cus_id, count( sah_code ) AS teller
FROM sah, sal
WHERE sah_type = “D”
AND sah.sah_id = sal.sah_id
GROUP BY sah_code
ORDER BY teller DESC
Welke levering van welke klant heeft meeste details?
SELECT sah_code, cus_id, count( sah_code ) AS teller
FROM sah, sal
WHERE sah_type = “D”
AND sah.sah_id = sal.sah_id
GROUP BY sah_code
ORDER BY teller DESC
LIMIT 0,1