My product
table looks like this:
id_product | product_count | product_name
1 | 10 | name1
2 | 20 | name2
3 | 20 | name3
4 | 52 | name4
5 | 30 | name5
6 | 50 | name6
And I want to do a query which result will be:
product_group_name | product_group_name | product_group_name |...more groups
30(sum) | 72(sum) | 50(sum) |...more values
where group will be id_product
, like (1,2 OR 3,4 OR 1,4,5) and group name will be alias.
Here is sql code to make a single column:
SELECT
cast(SUM(product.product_count) as float) as group_name
FROM
product
WHERE
product.id_product in (608,913,528,529,920,406,407,408,912,919,918,917,924,926,925)
and result of this query is:
| group_name |
| 200 |
Is it possible to add more columns with group names? It is important for them to be columns, not rows.