0% found this document useful (0 votes)
14 views5 pages

Practical 16 23

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

Practical 16 23

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

Practical 16: Create table employee and insert following records

TABLE:-EMPLOYEE
EmpNo EmpName Job Mgr City Hiredate Sal Comm DeptNo
Int NOT Char(20) Char(10) Int Varchar Date Int Numeric Int
NULL
7839 KING PRESIDENT DELHI 17-NOV-81 5000 10
7698 DEEPAK MANAGER 7839 KOLKATA 01-MAR-99 4500 30
7782 AKASH MANAGER 7839 DELHI 01-MAR-11 4000 10
7566 JONES MANAGER 7839 MUMBAI 02-APR-81 3500 20
7654 ALLEN SALESMAN 7698 RANCHI 08-JAN-97 2480 1500 30
7499 TURNER SALESMAN 7698 PATNA 20-FEB-81 1600 500 30
7844 JAMES SALESMAN 7698 MUMBAI 08-SEP-93 1500 0 30
7900 WARD CLERK 7698 CHENNAI 03-DEC-88 950 30
7521 FORD SALESMAN 7698 DELHI 22-FEB-89 1250 400 30
7902 DONALD ANALYST 7566 DELHI 03-DEC-87 3000
7369 SCOTT CLERK 7902 KOLKATA 17-NOV-96 800
7788 SMITH ANALYST 7566 NOIDA 09-OCT-86 3000 20
7876 ADAMS CLERK 7788 KANPUR 12-JAN-98 1100 20
7934 EVE CLERK 7782 MUMBAI 23-JAN-94 1300
Based on these tables write SQL statements for the following queries:
Q-1. Display the list of EmpNo and EmpName.
Q-2. Display the details of table Employee.
Q-3. List the City of Employee. (Without duplicates).
Q-4. Display the details of employee whose salary is greater than 4000.
Q-5. Display the details of employee whose commission is greater than 400.
Q-6. List the EmpNo and their manager whose dept no are 20.
Q-7. List the EmpNo and their manager whose dept no are 20 or 30.
Q-8. Display the EmpNo and their annual salary of all employees.
Q-9. Display the EmpNo who have been not allotted to any department.
Q-10. List the employee name in alphabetical order whose salary is more than 3500.
Q-11. Display the EmpNo and Name of salesman and their total monthly salary (salary +
commission) as TotalMonthlySalary.
Q-12. List the name of employee whose name starts with ‘A’.
Q-13. List the name of employee whose name does not start with ‘A’.
Q-14. List the name of employee in reverse alphabetical order whose name contains exactly five
characters.
Q-15. List the details of employee who belongs to either dept no 10 or 20.
Q-16. List the employee no who belongs to dept no 20 and salary is between 2000 and 3500.
Q-17. List the name of employee whose name ends with ‘D’.
Q-18. Display employee no, name and dept no as 40, who have been not allotted any department.
Q-19. Display the employee no and name whose name contains ‘R’ as third alphabet.
Q-20. List the details of employee who is not getting commission.
Practical 17: SQL Query Based on Aggregate Function
1. Display the total number of departments.
2. Count the total number of employees working in department number ‘30’.
3. Find the maximum and minimum salary for all employee.
4. Find the average salary paid to clerk.
5. Find the minimum salary for the employee who is living in Delhi.
6. List number of job available in employee table.
7. Find the total number of employees who is living in Delhi.
8. Count the number of employees who is getting commission.
9. Find the total salary paid to president, manager and analyst.
10. Find the average salary paid to other than manager, president and analyst.
11. Display the minimum and maximum salary paid among clerk, salesman and manager.
12. Display the hire date of first joining and last joining,
13. Find the average and maximum salary paid to manager and clerk.
14. Display the minimum, maximum and average salary paid to department number ‘30’.
15. Find the total salary of all employee whose name starts with ‘A’.

Practical 18: SQL Query Based on Group By and Having Clause


1. Display the department number and number of employees for each department.
2. Display total salary paid to each department.
3. Display total number of employees for each department where more than two employees are
working in the same department.
4. Display total salary paid to each job where numbers of employees are more than two for each job.
5. Display minimum and maximum salary paid for each job.
6. Display the number of employees for the city Kolkata, Delhi and Mumbai.
7. Display average salary paid to each department where numbers of employees are less than 5.
8. Display the number of employees for each city who is working in department number ‘30’.
9. Display average salary and number of employees for each city where more than two employees
are belonging to same city.
10. List the number of employees and their average salary for each department where two
employees are working
Practical 19:
Write the create command to create the following tables with suitable
constraints: -

Based on these tables write SQL statements for the following queries:
(I) Display the lowest and the highest classes for the game Cricket.
(II) Display the details of students in ascending order of adm no, who play any game.
(III) Display the Admission number, name, class, section, and roll number of the students whose
grade in Sports table is 'A'.
(IV) Display the name and phone number of the students of class 12 who play some game.
(V) Display details of the students of Cricket team.
(VI) Display the names and phone numbers of the students whose grade is 'A' and whose coach
is Narendra.
(VII) Display the number of students in each class who play any game.
(VIII) Display the number of students in class 10 who has grade ‘B’ in sport.
(IX) Display the Number of students with each coach.
(X) Display the number of students for each game.
Practical 20:
Write a python program to insert a record in student table of Test database
through user set of values.
Assume the following structure of student table:-
Field Data Type Size
Roll(Primary Int 4
Key)
Name Varchar 30
Address Char 40
Phone_no Int

Practical 21:
Write a python program to find and display the record of student from student
table of Test database. Program will search the record by the input roll no. of
student. If record not found, then display appropriate message.
Assume the following structure of student table:-
Field Data Type Size
Roll(Primary Int 4
Key)
Name Varchar 30
Address Char 40
Phone_no Int

Practical 22:
Write a python program to update the address of student in student table of Test
database. Program will search the record by the input roll no. of student. If
record not found, then display appropriate message.
Assume the following structure of student table:-
Field Data Type Size
Roll(Primary Int 4
Key)
Name Varchar 30
Address Char 40
Phone_no Int

Practical 23:
Write a python program to remove the record of student from student table of
Test database. Program will delete the record by the input roll no. of student. If
record not found, then display appropriate message.
Assume the following structure of student table:-
Field Data Type Size
Roll(Primary Int 4
Key)
Name Varchar 30
Address Char 40
Phone_no Int

You might also like