You are on page 1of 8

November 9

Test Paper (SQL & PL/SQL)

2021
ZEPTA Consulting & Technologies (Pvt.) Ltd
1. Write a SQL statement to display a string "This is SQL Exercise, Practice and Solution".

2. Write a query to display any three numbers in three columns.

3. Write a query to display the sum of two numbers 10 and 15

4. From the following table, write a SQL query to find the salespeople who lives in the City of '
Lahore'. Return salesperson's name, city.
Table Name: Employee

salesman_id name city Commission


5001 Shakil Karachi 0.15
5003 Rehan Lahore 0.13
5002 Salman Islamabad 0.11
5005 Adnan KPK 0.14
5006 Kamran Lahore 0.13
/*******************************************************************/

Table Name: nobel_win

YEAR SUBJECT WINNER FEES CATEGORY


1970 Physics Shakil 1000 Scientist
1970 Physics Rehan 1200 Scientist
1970 Chemistry Salman 1500 Scientist
1970 Physiology Adnan 1600 Scientist
1970 Physiology Kamran 1800 Scientist
1970 Literature Arsalan 1900 Linguist
1970 Economics Rameez 2000 Economist
1970 Physiology Salamat 2100 Scientist
1971 Physics Zeeshan 2200 Scientist
1971 Chemistry Mafaz 2300 Scientist
1971 Peace Shoaib 2400 Chancellor
1971 Literature Adnan Shah 2500 Linguist
1971 Economics Mioz 2600 Economist
1978 Peace Arshad 2700 President
2800 Prime
1978
Peace Farhan Minister
1994 Economics Imran 2900 Economist
3000 Prime
1994
Peace Yaqoob Minister
1994 Literature Saleem 3100 Linguist

5. From the above table “nobel_win”, write a SQL query to find the Nobel Prize winners in
'Chemistry' between the years 1965 to 1975. Begin and end values are included. Return
year, subject, winner, and category

6. From the above table “nobel_win”, Write a SQL query to show all details of the Prime
Ministerial winners after 1972 of “Arshad” and “Yaqoob”.
7. From the above table “nobel_win”, write a SQL query to find the details of the winners
whose first name matches with the string 'Sal'. Return year, subject, winner and category.

8. From the above table “nobel_win”, write a SQL query to combine the winners in Physics,
1970 and in Economics, 1971. Return year, subject, winner and category

9. From the above table “nobel_win”, write a SQL query to find the Nobel Prize winners in 1970
excluding the subjects Physiology and Economics. Return year, subject, winner and
category.

10. From the above table “nobel_win”, write a SQL query to find the Nobel Prize winners for the
subject not started with the letter 'P'. Return year, subject, winner and category. Order the
result by year, descending.
11. From the above table “nobel_win”, write a SQL query to select a range of students whose
fees is in the range Rs. 1600 to Rs. 2300. Begin and end values are included. Return year,
subject, winner and category. Order the result by Fees, ascending.

12. From the above table “nobel_win”, write a SQL query to calculate the average fees for the
subject equal to "Physics". Return avg.

13. From the above table “nobel_win”, write a PL/SQL block to calculate the increase 12% fees
of winner whose name is “Salman”
/*******************************************************************/
Table Name: employees

emp_nam
emp_id
e job_name manager_id hire_date salary commission dep_id
68319 FARHAN PRESIDENT 11/18/1991 6000 1001
66928 ADNAN MANAGER 68319 5/1/1991 2750 3001
67832 REHAN MANAGER 68319 6/9/1991 2550 1001
65646 SALMAN MANAGER 68319 4/2/1991 2957 2001
67858 SHAKEEL ANALYST 65646 4/19/1997 3100 2001
69062 RAMEEZ ANALYST 65646 12/3/1991 3100 2001
63679 MOIZ CLERK 69062 12/18/1990 900 2001
64989 MAFAZ SALESMAN 66928 2/20/1991 1700 400 3001
65271 SALAH SALESMAN 66928 2/22/1991 1350 600 3001
66564 SHOAIB SALESMAN 66928 9/28/1991 1350 1500 3001
68454 RAFIQ SALESMAN 66928 9/8/1991 1600 0 3001
68736 ABDULLAH CLERK 67858 5/23/1997 1200 2001
69000 TARIQ CLERK 66928 12/3/1991 1050 3001
69324 AMIR CLERK 67832 1/23/1992 1400 1001

14. From the above table “employees”, write a SQL query to find the managers. Return
complete information about the managers.

15. From the above table “employees”, write a SQL query to find those employees whose salary
is more than the salary of “SALMAN”. Return complete information about the employees.

16. From the above table“employees”, write a SQL query to find those employees who are
senior to “MAFAZ”. Return complete information about the employees.
17. From the above table “employees”, how to find employee salary, if the salary is equal to
“input parameter” with the help of cursor in function, if data not found then return
“Employee Salary not found from Input Parameter”?

18. From the above table “employees”, write a SQL query to find those employees who are
senior employees as of year 1991. Return complete information about the employees.
19. From the above table “employees”, write a SQL query to compute the total salary of the
designation MANAGER. Return total salary.

20. How to find “Consulting” from “ZEPTA Consulting & Technologies (Pvt) Ltd.”

21. Write a trigger on table “Vendors” where you have to check the length of vendor_name

Column. If length of vendor_name is less than 10 characters then display error message

“Invalid Value entered for vendor name”.

You might also like