Professional Documents
Culture Documents
EName
DOJ
Job
Dept_no
Salary
1010
Karan
01/06/80
Director
40
48,000
1023
Divakar
01/03/84
Manager
10
20,000
1038
Divya
01/05/94
Programmer
20
40,000
1055
Atul
01/09/95
Analyst
20
45,000
1059
Hritik
01/06/97
Programmer
20
40,000
1062
Akshay
01/08/99
Manager
30
25,000
1064
Ajay
01/10/99
Clerk
10
12,000
1066
Sanjay
01/02/00
Salesman
30
15,000
Comm
5000
1. Display details of all employees who earn between 10000 and 25000
_____________________________________________________________________
_____________________________________________________________________
2. Find the number of employees in the each department
_____________________________________________________________________
_____________________________________________________________________
3. Create a view containing details of employees of department number 20
_____________________________________________________________________
_____________________________________________________________________
4. Display details of all employees according to their department and seniority
_____________________________________________________________________
_____________________________________________________________________
5. Find all employees who are not managers
_____________________________________________________________________
_____________________________________________________________________
PART II
Write SQL statements for questions 1 to 5 using the table EMP
Empno
EName
DOJ
Job
Dept_no
Salary
1010
Karan
01/06/80
Director
40
48,000
1023
Divakar
01/03/84
Manager
10
20,000
1038
Divya
01/05/94
Programmer
20
40,000
1055
Atul
01/09/95
Analyst
20
45,000
1059
Hritik
01/06/97
Programmer
20
40,000
1062
Akshay
01/08/99
Manager
30
25,000
1064
Ajay
01/10/99
Clerk
10
12,000
1066
Sanjay
01/02/00
Salesman
30
15,000
Comm
5000
PART II
Write SQL statements for questions 1 to 5 using the table EMP
Empno
EName
DOJ
Job
Dept_no
Salary
1010
Karan
01/06/80
Director
40
48,000
1023
Divakar
01/03/84
Manager
10
20,000
1038
Divya
01/05/94
Programmer
20
40,000
1055
Atul
01/09/95
Analyst
20
45,000
1059
Hritik
01/06/97
Programmer
20
40,000
1062
Akshay
01/08/99
Manager
30
25,000
1064
Ajay
01/10/99
Clerk
10
12,000
1066
Sanjay
01/02/00
Salesman
30
15,000
Comm
5000
PART II
Write SQL statements for questions 1 to 5 using the table EMP
Empno
EName
DOJ
Job
Dept_no
Salary
1010
Karan
01/06/80
Director
40
48,000
1023
Divakar
01/03/84
Manager
10
20,000
1038
Divya
01/05/94
Programmer
20
40,000
1055
Atul
01/09/95
Analyst
20
45,000
1059
Hritik
01/06/97
Programmer
20
40,000
1062
Akshay
01/08/99
Manager
30
25,000
1064
Ajay
01/10/99
Clerk
10
12,000
1066
Sanjay
01/02/00
Salesman
30
15,000
Comm
5000
PART II
Write SQL statements for questions 1 to 5 using the table EMP
Empno
EName
DOJ
Job
Dept_no
Salary
1010
Karan
01/06/80
Director
40
48,000
1023
Divakar
01/03/84
Manager
10
20,000
1038
Divya
01/05/94
Programmer
20
40,000
1055
Atul
01/09/95
Analyst
20
45,000
1059
Hritik
01/06/97
Programmer
20
40,000
1062
Akshay
01/08/99
Manager
30
25,000
1064
Ajay
01/10/99
Clerk
10
12,000
1066
Sanjay
01/02/00
Salesman
30
15,000
Comm
5000
1. Give an incentive of Rs.5000 for the employees who joined before 1990
_____________________________________________________________________
_____________________________________________________________________
2. List the employees of software department drawing salary less than 40,000
_____________________________________________________________________
_____________________________________________________________________
3. List the employee who earns the highest in his/her department
_____________________________________________________________________
_____________________________________________________________________
4. Find the departments that have more than 2 types of job
_____________________________________________________________________
_____________________________________________________________________
5. Delete the employee with code 1010
_____________________________________________________________________
_____________________________________________________________________
PART II
Write SQL statements for questions 1 to 5 using the table EMP
Empno
EName
DOJ
Job
Dept_no
Salary
1010
Karan
01/06/80
Director
40
48,000
1023
Divakar
01/03/84
Manager
10
20,000
1038
Divya
01/05/94
Programmer
20
40,000
1055
Atul
01/09/95
Analyst
20
45,000
1059
Hritik
01/06/97
Programmer
20
40,000
1062
Akshay
01/08/99
Manager
30
25,000
1064
Ajay
01/10/99
Clerk
10
12,000
1066
Sanjay
01/02/00
Salesman
30
15,000
Comm
5000
1. Give the command to create the table EMP with the following constraints
Empno NOT NULL, primary key
Ename NOT NULL
Salary Default 12000 and salary >12000 and < 50000
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
2. List the lowest paid manager
_____________________________________________________________________
_____________________________________________________________________
3. Find the average salary and average total remuneration for each type. Remember
salesmen earn commission
_____________________________________________________________________
_____________________________________________________________________
4. Find all departments which have more than 2 employees
_____________________________________________________________________
_____________________________________________________________________
PART II
Write SQL statements for questions 1 to 5 using the table EMP
Empno
EName
DOJ
Job
Dept_no
Salary
1010
Karan
01/06/80
Director
40
48,000
1023
Divakar
01/03/84
Manager
10
20,000
1038
Divya
01/05/94
Programmer
20
40,000
1055
Atul
01/09/95
Analyst
20
45,000
1059
Hritik
01/06/97
Programmer
20
40,000
1062
Akshay
01/08/99
Manager
30
25,000
1064
Ajay
01/10/99
Clerk
10
12,000
1066
Sanjay
01/02/00
Salesman
30
15,000
Comm
5000
1. Remove the row which has any of empno: 1010, 1038, 1062
_____________________________________________________________________
_____________________________________________________________________
2. Assume that there is one more table DEPT in the database as shown below:
Dept_no
Dname
Location
10
Accounts
Jayanagar
20
Software
Indiranagar
30
Sales
Rajajinagar
40
Research
Koramangala
Give the query to display number, name, dept, location of employees earning more than
25000
_____________________________________________________________________
_____________________________________________________________________
3. Give the query to join the two tables EMP and DEPT
_____________________________________________________________________
_____________________________________________________________________
4. List the total number of employees
_____________________________________________________________________
_____________________________________________________________________
PART I
1) Write SQL commands for (a) to (d) using the following table FRIENDS :
No
Name
Address
DOB
Age
Karan
01-01-1980
18
Divakar
10-02-1981
17
Divya
15-03-1981
17
Atul
28-05-1980
18
Sanjay
5, Wilson Garden
18-06-1982
16
a)
_____________________________________________________________________
b) List the names in the ascending order of age
_____________________________________________________________________
_____________________________________________________________________
c) Increase age by 1 for all those born betweeen January and March
_____________________________________________________________________
d)
_____________________________________________________________________
Display all names which have r or y in them
_____________________________________________________________________
_____________________________________________________________________
2)
a)
b)
PART I
1) Write SQL commands for (a) to (d) using the following table FRIENDS :
No
Name
Address
DOB
Age
Karan
01-01-1980
18
Divakar
10-02-1981
17
Divya
15-03-1981
17
Atul
28-05-1980
18
Sanjay
5, Wilson Garden
18-06-1982
16
a)
_____________________________________________________________________
b) Change address to 1, Ram Sadan for name = Sanjay
_____________________________________________________________________
_____________________________________________________________________
c) Add a new row to the table. Use the following data :
Ravi, 45, Rose Garden, 20-08-81, 17
_____________________________________________________________________
d)
_____________________________________________________________________
List all those friends who are born in the year 1981
_____________________________________________________________________
_____________________________________________________________________
2)
a)
b)