Professional Documents
Culture Documents
Group by
Group by
DAY-11
IMPORTANT GROUP BY
SQL QUERIES
Created by:
Devikrishna R
LinkedIn - https://www.linkedin.com/in/devikrishna-r-
%F0%9F%87%AE%F0%9F%87%B3-92085678/
GROUP BY
--1. In the Person.Person table how many people are associated with each
person type?
--2. Using one Query, Find out how many products in Production.products are the
color ‘Silver’ and How many are as ‘Black’
--3. Using Sales.SalesOrderHeader how many sales occurred in each
salesPersonID between May 1 ,2011 and Deceber 31,2012. Order by the results by
the sale count in descending order.
--4. Select the count of TerritoryID based on the two tables Sales.Customer and
Sales.SalesTerritory group by based on the TerritoryID in high to low
--Answers
--1. In the Person.Person table how many people are associated with each
person type?
--1. In the Person.Person table how many people are associated with each
person type and order by their count desc?
--2. Using one Query, Find out how many products in Production.products are the
color ‘Silver’ and How many are as ‘Black’
---ORDER
--4. Select the count of TerritoryID based on the two tables Sales.Customer and
Sales.SalesTerritory group by based on the TerritoryID in high to low