How to display products under Category in sql in a table

后端 未结 3 1206
轮回少年
轮回少年 2021-01-28 05:48

I have the following table:

\"product\"

where the products are in different categories and i am excepting

3条回答
  •  情话喂你
    2021-01-28 06:37

    Using Rollup you would do it like this.

    SELECT  COALESCE(product,category,'Total') Category,
            SUM(VALUE) cost
    FROM    products
    GROUP BY ROLLUP(category,product)
    

提交回复
热议问题