Home > database >  This generated in the subtotal line written in SQL is how to do?
This generated in the subtotal line written in SQL is how to do?

Time:09-18

CodePudding user response:

https://bbs.csdn.net/topics/390676351

CodePudding user response:

Small SUM function with GROUP BY:
 
SELECT goods number, the SUM (quantity), SUM (sales),...
FROM the table
GROUP BY commodity number;


If you also need to calculate total, plus WITH ROLLUP:
 
SELECT goods number, the SUM (quantity), SUM (sales),...
FROM the table
GROUP BY commodity code WITH a ROLLUP;
  • Related