0% found this document useful (0 votes)
5 views17 pages

63 D 634 D 5413 A 4 SQLTASKS2

Uploaded by

ukkhan430
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views17 pages

63 D 634 D 5413 A 4 SQLTASKS2

Uploaded by

ukkhan430
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

SUBMITTED BY:

Uzair Khalid Khan


34201-96576167-7
[email protected]

SUBMITTED TO:
Sir Bilal Rustom
SELECT Suppliers.ContactName, Products.ProductName, Suppliers.Phone
FROM Suppliers Inner Join Products
ON Suppliers.SupplierID = Products.SupplierID;
Select customers.customername, customers.address,orders.orderid
From orders left join customers
On orders.shipperid=customers.customerid;
Select Shippers.ShipperID, Shippers.ShipperName, Orders.OrderID
From Shippers Left Join Orders
Where Shippers.ShipperID = Orders.ShipperID
Order by Shippers.ShipperID;
Select Employees.EmpoyeeID, Employees.FirstName, Orders.OrderID
From Orders Right Join Employees
On Orders.ShipperID = Employees.EmployeeID
Order by Employees.EmployeeID;
SELECT * FROM ORDERS;
SELECT CUSTOMERS.CUSTOMER_NAME, ORDERS.ORDERID
FROM CUSTOMERS
FULL OUTER JOIN ORDERS
ON CUSTOMERS.CUSTOMERID=ORDERS.CUSTOMERID
ORDER BY CUSTOMERS.CUSTOMERNAME;
SELECT * from customers
where city IN (select city from customers
group by city
having count (*)>1)
SELECT DISTINCT city FROM customers
UNION
SELECT DISTINCT city FROM suppliers;
Task8: Write an SQL query that lists the number of customers in each
country, sorted high to low

SELECT country, COUNT(*) as customer_count


FROM customers
GROUP BY country
ORDER BY customer_count DESC;
Task9: Write an SQL query that lists the number of customers in each
country, sorted high to low (Only include countries with more than 3
customers)

SELECT COUNT(CustomerID), Country


FROM Customers
GROUP BY Country
HAVING COUNT(CustomerID) > 3
ORDER BY COUNT(CustomerID) DESC;
SELECT SupplierName
FROM Suppliers
WHERE EXISTS (SELECT ProductName FROM Products WHERE SupplierId =
Suppliers.supplierId AND Price < 20);
GET:

POST:
PUT:

Delete:
Get:

Post:
Put:

Delete:

You might also like