1SELECT CityID,
2 COUNT(*) NumberOfDogsInThisCity,
3 SUM(CASE WHEN DogName = 'Tedy' THEN Wheight ELSE 0 END) WheightOfAllDogWithNameTedy
4FROM Dogs
5GROUP BY CityID
1SELECT cust_city, SUM (opening_amt + receive_amt)
2FROM customer
3GROUP BY cust_city;
4
1// Use SQL Group By clause after the Where clause
2// Any column in the select list must either be in the Group By clause
3// or part of an agregation statement, like the Sum() statement
4// Multiple columns can be included in the Group By Clause seperated by a comma
5// Multiple columns stipulate the order tree. Order by
6// first column, then second ... etc
7
8Select LastName, FirstName, Sum(LeaveDays), Max(age)
9From EmployeeProjects
10Where StartDate > '2020-01-01'
11Group By LastName, FirstName