SQL Practice Questions
SQL Practice Questions
Cust_I Sale_Amoun
d Date t
1 2011-02-09 00:00:00 700
2 2010-09-09 00:00:00 600
1 2010-09-09 00:00:00 900
3 2010-09-09 00:00:00 200
Question 1 - You need to write a SQL to print the Customer First Name, Last Name and the total sales
happened for all the customers. If there is no sales record for a particular customer, it should print the
first name, last name of the customer and the total sales amount as 0. Below is the sample output.
SalesPerCustome
FirstName LastName r
Jitu Bagwani 200
Sherine Mathew 0
Atul Mohan 1600
Armaan Shaah 600
Solution 1
ON Customer.CustomerID = Sales.Cust_Id
ORDER BY Customer.LastName
Question 2 - You need to write a SQL to print the Customer First Name, Last Name and the total sales
happened for all the customers whose year of birth is 1983 or thereafter. If there is no sales record for a
particular customer, it should print the first name, last name of the customer and the total sales amount
as 0. Below is the sample output.
ON Customer.CustomerID = Sales.Cust_Id
WHERE YEAR(Customer.Dob)>'1982'
ORDER BY Customer.LastName