mercredi 25 mars 2015

SQL SUM of different product groups in one query?


I have a table with the following columns:



PRODUCT_ID | PRODUCT_NAME | GROUP_ID | GROUP_NAME | PRICE


GROUP_ID and GROUP_NAME are not UNIQUE. Can I make a selection which just returns each GROUP_ID with its GROUP_NAME and its SUM(PRICE)?


Or will I have to make a SELECT query for each GROUP?


For example: I have 12000 PRODUCTs which are in 14 GROUPs. My query should then only return 14 rows.





Aucun commentaire:

Enregistrer un commentaire