The GROUP BY clause is used to group a result set by one or more columns.
Syntax
SELECT [ DISTINCT ]
{ * | projectItem [, projectItem ]* }
FROM tableExpression
[ GROUP BY { groupItem [, groupItem ]* } ];
Example
- Test data
Customer OrderPrice Bush 1000 Carter 1600 Bush 700 Bush 300 Adams 2000 Carter 100 - Statement
SELECT Customer,SUM(OrderPrice) FROM xxx GROUP BY Customer;
- Result
Customer SUM(OrderPrice) Bush 2000 Carter 1700 Adams 2000