0% found this document useful (0 votes)
1 views

tutorial set 4 - SQL -student

The document contains a series of SQL exercises that require writing queries for various tasks, such as displaying information from salesmen, orders, customers, Nobel prize winners, products, and employees. Each exercise specifies the required output and the relevant tables to use. The exercises cover a range of SQL concepts including selection, filtering, ordering, and aggregation.

Uploaded by

temmybryan74
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

tutorial set 4 - SQL -student

The document contains a series of SQL exercises that require writing queries for various tasks, such as displaying information from salesmen, orders, customers, Nobel prize winners, products, and employees. Each exercise specifies the required output and the relevant tables to use. The exercises cover a range of SQL concepts including selection, filtering, ordering, and aggregation.

Uploaded by

temmybryan74
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Exercice 1 :

Write a SQL statement to display all the information of all salesmen


Table 1: Sample table: salesmen
salesman_id | name | city | commission
-------------+------------+----------+------------
5001 | James Hoog | New York | 0.15
5002 | Nail Knite | Paris | 0.13
5005 | Pit Alex | London | 0.11
5006 | Mc Lyon | Paris | 0.14
5007 | Paul Adam | Rome | 0.13
5003 | Lauson Hen | San Jose | 0.12

Exercise 2:
Write a SQL statement to display specific columns like name and commission for all the
salesmen. (table 1)

Exercise 3:
1. Write a SQL statement to display a string "This is SQL Exercise, Practice and
Solution".
2. Write a query to display three numbers in three columns.
3. Write a query to display the sum of two numbers 10 and 15 from RDMS sever.
4. Write a query to display the result of an arithmetic expression.

Exercise 4:
Write a query to display the columns in a specific order like order date, salesman id, order
number and purchase amount from for all the orders.
Table 2: Sample table: orders
ord_no purch_amt ord_date customer_id salesman_id
---------- ---------- ---------- ----------- -----------
70001 150.5 2012-10-05 3005 5002
70009 270.65 2012-09-10 3001 5005
70002 65.26 2012-10-05 3002 5001
70004 110.5 2012-08-17 3009 5003
70007 948.5 2012-09-10 3005 5002
70005 2400.6 2012-07-27 3007 5001
70008 5760 2012-09-10 3002 5001

Exercise 5
Write a query which will retrieve the value of salesman id of all salesmen, getting orders from
the customers in orders table without any repeats. USE TABLE 2

Exercise 6
Write a SQL statement to display all the information for those customers with a grade of 200.
Table 3: Customer
customer_id | cust_name | city | grade | salesman_id
-------------+----------------+------------+-------+-------------
3002 | Nick Rimando | New York | 100 | 5001
3007 | Brad Davis | New York | 200 | 5001
3005 | Graham Zusi | California | 200 | 5002
3008 | Julian Green | London | 300 | 5002
3004 | Fabian Johnson | Paris | 300 | 5006
3009 | Geoff Cameron | Berlin | 100 | 5003
3003 | Jozy Altidor | Moscow | 200 | 5007
3001 | Brad Guzan | London | | 5005

Exercise 7:
Write a SQL query to display the order number followed by order date and the purchase amount
for each order which will be delivered by the salesman who is holding the ID 5001.
USE TABLE 2.

Exercise 8:
Using table 4 below:
1. Write a SQL query to display the Nobel prizes for 1970.
2. Write a SQL query to know the winner of the 1971 prize for Literature
3. Write a SQL query to display the year and subject that won 'Dennis Gabor' his prize
4. Write a SQL query to give the name of the 'Physics' winners since the year 1950
5. Write a SQL query to Show all the details (year, subject, winner, country) of the
Chemistry prize winners between the year 1965 to 1975 inclusive
6. Write a SQL query to show all details of the Prime Ministerial winners after 1972 of
Menachem Begin and Yitzhak Rabin
7. Write a SQL query to show all the details of the winners with first name Louis
8. Write a SQL query to show all the winners in Physics for 1970 together with the winner
of Economics for 1971
9. Write a SQL query to show all the winners of nobel prize in the year 1970 except the
subject Physiology and Economics.
10. Write a SQL query to show the winners of a 'Physiology' prize in an early year before
1971 together with winners of a 'Peace' prize in a later year on and after the 1974.
11. Write a SQL query to find all details of the prize won by Johannes Georg Bednorz
12. Write a SQL query to find all the details of the nobel winners for the subject not started
with the letter 'P' and arranged the list as the most recent comes first, then by name in
order.
13. Write a SQL query to find all the details of 1970 winners by the ordered to subject and
winner name; but the list contains the subject Economics and Chemistry at last
Table 4: nobel_win
YEAR SUBJECT WINNER COUNTRY CATEGORY
---- ------------------------- --------------------------------------------- ------------------------- ------------
1970 Physics Hannes Alfven Sweden Scientist
1970 Physics Louis Neel France Scientist
1970 Chemistry Luis Federico Leloir France Scientist
1970 Physiology Ulf von Euler Sweden Scientist
1970 Physiology Bernard Katz Germany Scientist
1970 Literature Aleksandr Solzhenitsyn Russia Linguist
1970 Economics Paul Samuelson USA Economist
1970 Physiology Julius Axelrod USA Scientist
1971 Physics Dennis Gabor Hungary Scientist
1971 Chemistry Gerhard Herzberg Germany Scientist
1971 Peace Willy Brandt Germany Chancellor
1971 Literature Pablo Neruda Chile Linguist
1971 Economics Simon Kuznets Russia Economist

Exercise 8:
Table 5: Product
PRO_ID PRO_NAME PRO_PRICE PRO_COM
------- ------------------------- ---------- ----------
101 Mother Board 3200 15
102 Key Board 450 16
103 ZIP drive 250 14
104 Speaker 550 16
105 Monitor 5000 11
106 DVD drive 900 12
107 CD drive 800 12
108 Printer 2600 13
109 Refill cartridge 350 13
110 Mouse 250 12
1. Write a SQL query to find all the products with a price between Rs.200 and Rs.600
2. Write a SQL query to calculate the average price of all products of the manufacturer
which code is 16.
3. Write a SQL query to find the item name and price in Rs.
4. Write a SQL query to display the name and price of all the items with a price is equal
or more than Rs.250, and the list contain the larger price first and then by name in
ascending order
5. Write a SQL query to display the average price of the items for each company, showing
only the company code
6. Write a SQL query to find the name and price of the cheapest item(s)

Exercise 9
Table 6: Employee
EMP_IDNO EMP_FNAME EMP_LNAME EMP_DEPT
--------- --------------- --------------- ----------
127323 Michale Robbin 57
526689 Carlos Snares 63
843795 Enric Dosio 57
328717 Jhon Snares 63
444527 Joseph Dosni 47
659831 Zanifer Emily 47
847674 Kuleswar Sitaraman 57
748681 Henrey Gabriel 47
555935 Alex Manuel 57
539569 George Mardy 27
733843 Mario Saule 63
631548 Alan Snappy 27
839139 Maria Foster 57
1. Write a query in SQL to find the last name of all employees, without duplicates
2. Write a query in SQL to find the data of employees whose last name is 'Snares'
3. Write a query in SQL to display all the data of employees that work in the department
57.

You might also like