Ik heb een simpele query op onze sales tabel wat de som van het aantal verkochte producten per klant weergeeft. Ik wil dit aanpassen zodat het alleen het aantal weergeeft van de grootste klant van dit product.
Huidige SQL:
SELECT
Op.customer,
op.product,
sum(op.quantity) aantal
FROM
op
WHERE
(op.year = '2008')
GROUP BY
1,
2
Huidige resultaat
product customer quantity
100 1001 25
100 1002 10
100 1003 5
100 1004 1
Gewenst resultaat
product customer quantity
100 1001 25
Iemand een idee?
Huidige SQL:
SELECT
Op.customer,
op.product,
sum(op.quantity) aantal
FROM
op
WHERE
(op.year = '2008')
GROUP BY
1,
2
Huidige resultaat
product customer quantity
100 1001 25
100 1002 10
100 1003 5
100 1004 1
Gewenst resultaat
product customer quantity
100 1001 25
Iemand een idee?