You are on page 1of 12

‫عبدالرحمن ابراهيم طه محمد العمري‬

Group: B1

Q11: For the following customers table

Customer_ Customar City Postal Country


ID _Name Code
1 Ahmed Bonn 50765 Germany
2 Basem New York 18659 USA
3 Gamal Orlando 14676 USA
4 Iman London 76787 UK
5 Yaser Paris 85086 France
6 Zakaria Berlin 50876 Germany
write SQL statements to do the following:
1. List the names and cities for all customers

2. List all data in the table

172
‫عبدالرحمن ابراهيم طه محمد العمري‬
Group: B1

3. List only the distinct values from the City column

4. List all customers whose country is USA

5. List all customers from Germany and their city is Bonn

6. List all customers whose city is Berlin or Bonn

173
‫عبدالرحمن ابراهيم طه محمد العمري‬
Group: B1

7. List all customers from Germany and city is Berlin or Bonn

8. List all customers sorted by country

9. List all customers sorted DESCENDING by the Country

174
‫عبدالرحمن ابراهيم طه محمد العمري‬
Group: B1

10. List all customers sorted by Country and Customer_Name

11. Insert a new row, but only insert data in the Customer_ID,
Customer_Name and Country columns

175
‫عبدالرحمن ابراهيم طه محمد العمري‬
Group: B1

12. Update the customer "Ahmed" with a new postal code 48654
and City is Hamburg

13. Delete the customer "Iman" from the "Customers" table

14. List the two first records

176
‫عبدالرحمن ابراهيم طه محمد العمري‬
Group: B1

15. List the first 50% of the records

16. List all customers with a City starting with the letter "G"

17. List all customers with a City ending with the letter "e"

18. List all customers with a Country containing "SA"

177
‫عبدالرحمن ابراهيم طه محمد العمري‬
Group: B1

19. List all customers with Country NOT containing "SA"

20. List all customers with a City starting with "b", "s", or "p"

21. List all customers with a City ending with "c", "e", or "n"

22. List all customers whose City NOT starting with "b" or "p"

178
‫عبدالرحمن ابراهيم طه محمد العمري‬
Group: B1

23. List all customers with a City of "Paris" or "London"

Q12: For the following products table

Product Product_ Supplier Category Unit Price


_ID Name _ID _ID
1 Suger 1 1 1 1KG 6
2 Oil 2 2 1 Litter 15
3 Milk 4 3 1 bottle 20
4 Tee 3 4 100 Bags 22
5 Butter 2 2 1 KG 24.5
write SQL statements to do the following:
1. List all products with a price BETWEEN 10 and 20:

179
‫عبدالرحمن ابراهيم طه محمد العمري‬
Group: B1

2. List the products outside the range of the previous example,


use NOT BETWEEN:

3. List all products with a price BETWEEN 10 and 20, but


products with a Category_ID of 1,2, or 3 should not be
displayed:

4. List all products with a Product_Name beginning with any of


the letter BETWEEN 'C' and 'N':

180
‫عبدالرحمن ابراهيم طه محمد العمري‬
Group: B1

Q13: For the following tables

Order_ID Customer_ID OrderDate


101 2 18-09-2014
102 37 19-09-2014
103 77 20-09-2014

Customer_ID Customer_Name Contact_Name Country


101 Ahmed George France
102 Mostafa Maria Italy
103 Tamer Antonio Italy
write SQL statements to retrieve the name of customer whose
order date is 19-09-2014?

Q14: For the following customer and order tables

181
‫عبدالرحمن ابراهيم طه محمد العمري‬
Group: B1

Customer Table
Customer_ Customar_ Contact_ City Postal Country
ID Name Name Code
1 Ahmed Maria Bonn 50765 Germany
2 Basem Ana New York 18659 USA
6 Zakaria Maria Berlin 50876 Germany

Order Table
Order_ID Customar_ID Employee_ID Order_Date Shipper_ID
10308 2 7 01-10-2014 3
10309 66 8 02-10-2014 1
10310 56 5 03-10-2014 5
1. List all customers with orders

2. List all customers and any orders they might have

Q15: Create a table called "Persons" that contains five columns:


PersonID, LastName, FirstName, Address, and City

182
‫عبدالرحمن ابراهيم طه محمد العمري‬
Group: B1

Add a column named "Birth_Date" in the "Persons" table.

183

You might also like