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

SQL Final Exam

The document describes an SQL exam with 3 sections worth a total of 30 marks. Section A contains 4 multiple choice questions worth 2 marks each. Section B contains 5 long-form questions worth 3 marks each. Section C contains 1 long-form question worth 7 marks involving creating an employee table and performing queries on it.

Uploaded by

papers scan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
462 views

SQL Final Exam

The document describes an SQL exam with 3 sections worth a total of 30 marks. Section A contains 4 multiple choice questions worth 2 marks each. Section B contains 5 long-form questions worth 3 marks each. Section C contains 1 long-form question worth 7 marks involving creating an employee table and performing queries on it.

Uploaded by

papers scan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

SQL 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.

SECTION B – 3*5 = 15 marks


5. Write a query to fetch ‘empname’ from ‘employeedetails’ table and ‘salary’ from ‘employeesalary’
table; return employee details even if the salary is not present for the employee. (Link – empid in
both the tables)

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).

SECTION C – 1*7 = 7 marks


10. Create the table ‘employee’ with the below fields and make the id field as primary key

id name department manager salary


1 John IT 9 40000
2 Alex Corp 0 80000
3 Linda IT 9 35000
4 Rahul Purchase 8 30000
5 Ismail Purchase 8 44000
6 Zheng Sales 7 25000
7 Reiki Sales 2 60000
8 Aris Sales 2 59000
9 Jena IT 2 66000
10 Bonny IT 9 66000

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

You might also like