SQL Final Exam
SQL Final Exam
Total Marks = 30
SECTION A – 2*4 = 8 marks
1. What is the difference between count(*) and count(id) ?
2. Write a query to select all the students from table ‘stud’ whose name begins with 'S'
3. Write a query to select all the records for which ‘gender’ is female or ‘age’ > 18 from the ‘emp’
table.
4. Write a query to get the highest and lowest paid salary from each ‘dept’ from ‘emp’ table.
6. Write a query to create a table named ‘persons’ with id, fname, lname, salary where salary should
accept values in the range 10000 to 90000 and set id as primary key.
7. Write a query to list the employee details (‘empid’, ‘empname’, ‘salary’) who has the same ‘salary’
from the employee table?
8. Write a query to find the number of products with a price more than or equal to Rs.350
(‘pro_price’) from the table item_mast.
9. Write a query to display the name of each company (com_name) from company_mast table; also
display price (pro_price) for their most expensive product along with prodcut Name (pro_name)
from item_mast table (Link – com_id in company_mast with pro_com in item_mast).
Step 2 : Insert all the records as shown above and load the table employee like above
Step 3 : Write a query to list the employees who are not managers
Step 4 : Write a query to list the name of the managers who handle more than 2 reportees.
Step 5 : Write a query to fetch the employee whose salary is second lowest.
Step 6 : Write a query to fetch the records whose salary falls in the range 50000 and 80000