You are on page 1of 7

Q: show the number of customers in each country who has more than 5 customers.

A: SELECT COUNT (*) as NUMBEROFCUSTOMER, COUNTRY FROM CUSTOMERS


GROUP BY COUNTRY HAVING COUNT (*) >5

Q: Show the number of customers in each countries. “Count does not need to put with collum”

A: SELECT COUNT (*) as NUMBEROFCUSTOMER, COUNTRY FROM CUSTOMERS


GROUP BY COUNTRY

Q: SELECT COUNTRY, COUNT(*) FROM CUSTOMERS GROUP BY COUNTRY;

Q: SELECT PRICE, SUM(Price), AVG(price) as AveragePrice FROM Products Group By


ProductName;

Q: show the number of customers in each country who has more than 5 customers. BIG TO SMALL

A: SELECT COUNT (*) as NUMBEROFCUSTOMER, COUNTRY FROM CUSTOMERS


GROUP BY COUNTRY HAVING COUNT (*) >5 ORDER BY NUMBEROFCUSTOMER DESC

Q: Find out all the customers who belong to Berlin

A: SELECT * FROM Customers WHERE City= 'Berlin';

Q: Find out all the customers who belong to Berlin & london

A: SELECT * FROM Customers WHERE City= 'Berlin' or City='London'

A: SELECT * FROM Customers Where City = 'Berlin' or City='London' ;

Q: Show the number of customers who live in cities from USA and Sweden. The highest number of
customers living city should come first.

A: SELECT COUNT(*)as NumberOfCustomers, City FROM Customers WHERE Country = 'USA' or


Country = "Sweden" GROUP BY City ORDER BY COUNT(*) DESC

dOSUT SCREENSHORT GULA DE NICHE

Solve the following query

1. Show the contact name from customer table who lives in Germany.
Ans: SELECT CustomerName FROM Customers where Country = "Germany"

2. How many suppliers are there from USA?

Select count(*) as number_of_suppliers, Country from Suppliers where Country ='USA'

3. Show the product name from Products where the price of the product is more than 20.
Select Price,ProductName from Products where price > 20

Select ProductName From products where price > 20;


4. Show the number of orders productid wise which has more than 30 in quantity from
orderdetails.

select count(*) as number_of_orders, ProductID from OrderDetails group by ProductID


having Quantity > 30
5. Show the full details of productid number 51 from products.

select * from Products where ProductID = 51

Galiv: SELECT * FROM Customers where CustomerID=51;

6. What Is the price of Maxilaku? [Maxilaku is a product]

If you can answer 5 questions, you will get full marks. If you answer
six questions you will get bonus marks.
For applying the SQL: https://www.w3schools.com/sql/trysql.asp?
filename=trysql_select_all

Instructions:
1. You must run each question in the sql link (given upward).
2. After executing the command successfully, take a screenshot
and paste into a word file.
3. Upload it into the assignment section and DO NOT FORGET TO
TURN THE ASSIGNMENT IN. (TURN IN MUST)

You might also like