Showing posts with label SQL GROUP BY Statement. Show all posts
Showing posts with label SQL GROUP BY Statement. Show all posts

24 May 2011

SQL GROUP BY Statement

SQL GROUP BY Statement:

The GROUP BY statement is used in conjunction with the aggregate functions to group the result-set by one or more columns.

SELECT Customer,SUM(OrderPrice) FROM Orders
GROUP BY Customer


GROUP BY More Than One Column

SELECT Customer,OrderDate,SUM(OrderPrice) FROM Orders
GROUP BY Customer,OrderDate

Finding duplicate records in SQL Server

 Finding duplicate records in SQL Server 1. The GROUP BY and HAVING Method This is the most standard approach. It is best used when you on...