0% found this document useful (0 votes)
3 views11 pages

Comp Record

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)
3 views11 pages

Comp Record

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/ 11

SQL EXERCISE 1

Create the tables EMPL and DEPT according to the given structure.
Table structure of DEPT

FIELD NAME DATA TYPE CONSTRAINTS


Deptno Integer Primary key
Dname Varchar(20) Not null
Loc Varchar(20)

Table structure of EMPL


FIELD DATA TYPE CONSTRAINTS
NAME
Empno Integer Primary key
Ename Varchar(20) Not null
Job Varchar(20)
Mgr Float
Hiredate Date
Sal Double
Comm Double

Deptno Integer Foreign key


Records to be inserted in table DEPT
Records to be inserted in table DEPT

1. Display the employee name and department no: of employee no:8844

2.Display the employee name, job and start date of employees hired between Feb 20,1991 and May 1,
1991(both dates are inclusive).
3. Display the employee name and department number for all employees in departments 10 and 30 in
alphabetical order by name

4.Display the name and salary of employees who earn more than Rs.1500 and are in departments 10 or 30.
Label the columns as Employee and Monthly Salary respectively

5.Display the name and hiredate of every employee who was hired in 1992
6.Display the name , salary and job of all employees whose job is Clerk or Analyst and their salary is equal to
Rs.1000 or Rs.3000 or Rs.5000.

7.Display the name and department number of all employees who earn a commission.

8. Display the employee name and amount of the salaries. Sort the data in descending order of salary.
9. Display the number of people with the same job.

10. Display the number of managers without listing them

11. Display the difference between the highest and lowest salaries. Label the column Difference.

12. Display the empno, name and job of all employees who are not managers.
13. Display the name, salary and department of employees whose name starts with ‘A’.

14.Display details of employees having salary more than 2500 in the alphabetical order of their names.

15.Display the name of the employee whose name contains ‘A’ as fourth alphabet.
16. Display the name and department name of the employee who is having ‘L’ as any alphabet of the name

17.List the name, job, department number, department name and joining date of all the employees who have
four lettered name.

18. Display the name, salary and department number of all who do not have a commission.
19. Display the number of employees in each grade(job) and total salary for each grade of employees

20. Display the jobs where the number of employee are less than 3.

21. Display name, department number and department name of all employees
22. Display department number, department name, employee number, employee name, salary and job of all
employees from sales department

23. Display the name, job, department number and department name of all employees who work in ‘Chennai’.

24. Display name, department number and location of employee named ‘Anoop’.
25. Display name, department name, job and salary of all analysts.

26. Display employee number, department number, department name, location and salary of all employees.

27. Display employee names with their department details

You might also like