I have this table
PRODUCT | PROVINCE | INCOME |
---|---|---|
Apple | Seville | 13.2 |
Melon | Almeria | 3.6 |
… | … | … |
I tried this:
SELECT PRODUCT, PROVINCE, MAX(TOTAL) FROM ( SELECT PRODUCT, PROVINCE, SUM(INCOME) TOTAL FROM SALES GROUP BY PRODUCT,PROVINCE ) GROUP BY PRODUCT,PROVINCE;
Advertisement
Answer
SELECT PRODUCTO, PROVINCIA FROM VENTAS WHERE RECAUDACION IN (SELECT MAX(RECAUDACION) FROM VENTAS GROUP BY PROVINCIA) GROUP BY PROVINCIA, PRODUCTO;