Sie sind auf Seite 1von 3

SQL Practice

Databases and Web Services (CO19-320302)


Jacobs University Bremen

1 Instructions
The solutions to these problems will be posted on moodle.
This homework is not graded, it is purely for practice purposes.

1.1 Q1: Salesmen


Table name: salesmen
salesman id name city commission rate
90063 James Dean New York 0.15
90011 Naomi Watts Paris 0.13
90101 Peter Andrews London 0.11
90210 Matthew Mays Paris 0.14
90066 Lauren Hens Jakarta 0.12
90055 Paul Smith Rome 0.13
Table name: orders
order num purchase amt order date customer id salesman id
70001 200 2018-10-05 20005 90011
70009 270.99 2018-09-10 20001 90101
70002 65.99 2018-10-05 20002 90063
70004 305 2018-08-17 20009 90066
70007 1000 2018-09-10 20005 90011
70005 2400 2018-07-27 20007 90063
70008 5760 2018-09-10 20002 90063
70010 1980 2018-10-10 20004 90210

1. Retrieve the name of all salesmen who are located in Paris

2. Retrieve the name of the salesman with the lowest commission rate

3. Retrieve the salesman ID of all the salesmen that have completed sales (without any repeating
values).

4. Retrieve the purchasing amount, order date and customer ID of all sales made by Salesman
ID: 90011

1
1.2 Q2: Nobel Prizes
Table name: nobel prizes
year subject winner county 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
1978 Peace Anwar al-Sadat Egypt President
1978 Peace Menachem Begin Israel Prime Minister
1987 Chemistry Donald J. Cram USA Scientist
1987 Chemistry Jean-Marie Lehn France Scientist
1987 Physiology Susumu Tonegawa Japan Scientist
1994 Economics Reinhard Selten Germany Economist
1994 Peace Yitzhak Rabin Israel Prime Minister
1987 Physics Johannes Georg Bednorz Germany Scientist
1987 Literature Joseph Brodsky Russia Linguist
1987 Economics Robert Solow USA Economist
1994 Literature Kenzaburo Oe Japan Linguist

1. Write a simple query to display the Nobel Prizes for 1970.

2. Display the name and nationality of winner of the 1971 Physics Nobel prize.

3. What year and for which subject did Joseph Brodsky get his award for?

4. Show all the details of chemistry Nobel prize winners between the years 1965 and 1975
inclusive.

5. Write a query to display all the details of winners with the first name ’Simon’.

6. Display everything in descending order by year, do not display any Physics awards.

2
1.3 Q3: Employees
Table name: workers
worker id first name last name salary joining date department
001 Mike Smith 50000 2018-02-20 HR
002 Nick Jones 80000 2018-06-11 Admin
003 Victor Delores 30000 2018-02-20 HR
004 Adriana Sierra 50000 2018-02-20 Admin
005 Valeria Gonzalez 50000 2018-06-11 Admin
006 Victoria Neruda 45000 2018-06-11 Account
007 Samuel Banks 75000 2018-01-20 Account
008 Gerald Castro 90000 2018-04-11 Admin
Table name: Title
worker ref id worker title
1 Manager
2 Executive
8 Executive
5 Manager
4 Asst. Manager
7 Executive
6 Lead
3 Lead

1. Print all names of workers with ’a’ in their first name.

2. Print the full name of workers with salaries ≥ 45000 and ≤ 80000.

3. Query the number of workers in each department, in descending order.

4. Print all the details of workers who are also managers.

5. Print the details of the highest earning employee.

• Bonus: Print the details of the nth (this case, n = 3) highest earning employee.

6. Query departments with more than 3 people working in them.

7. Write a query to display the name and salary of the highest earning employee in each depart-
ment.

Das könnte Ihnen auch gefallen