Professional Documents
Culture Documents
DEPARTMENT EMPLOYEE
+------+---------+--------+--------+------+ +----+---------+--------+--------+------+-------+------+
| Dept | DName | MinSal | MaxSal | HOD | | No | Name | Salary | Zone | Age | Grade | Dept |
+------+---------+--------+--------+------+ +----+---------+--------+--------+------+-------+------+
| 10 | Sales | 25000 | 32000 | 1 | | 1 | Mukul | 30000 | West | 28 | A | 10 |
| 20 | Finance | 30000 | 50000 | 5 | | 2 | Kritika | 35000 | Centre | 30 | A | 10 |
| 30 | Admin | 25000 | 40000 | 7 | | 3 | Naveen | 32000 | West | 40 | NULL | 20 |
+------+---------+--------+--------+------+ | 4 | Uday | 38000 | North | 38 | C | 30 |
| 5 | Nupur | 32000 | East | 26 | NULL | 20 |
| 6 | Moksh | 37000 | South | 28 | B | 10 |
| 7 | Shelly | 36000 | North | 26 | A | 30 |
+----+---------+--------+--------+------+-------+------+
a) Based on these tables write SQL statements for the following queries:
i Display the details of all the employees who work in Sales department.
mysql> select * from employee where dept=(select dept from department where dname='Sales');
ii Display the Salary, Zone, and Grade of all the employees whose HOD is Nupur.
mysql> select salary,zone,grade from employee where dept=(select dept from department where hod=(select no from
employee where name='Nupur'));
iii Display the Name and Department Name of all the
employees.
mysql> select name,dname from employee,department where employee.dept=department.dept;
iv Display the names of all the employees whose salary is not within the specified range for the corresponding department.
mysql> select name from employee,department where employee.dept=department.dept and salary between minsal and
maxsal;
V Display the name of the department and the name of the corresponding HOD for all the departments.
mysql> select dname,name from department,employee where hod=no;
b) Identify the Foreign Keys (if any) of these tables. Justify your choices.
Dept is the Foreign Key in Employee table, because it’s the only column/field in common to join the two given tables.
1 comment:
Publish Preview
Blog Archive
► 2014 (1)
► 2013 (11)
▼ 2012 (27)
► December (1)
► November (2)
► October (1)
▼ August (20)
Output Questions - JavaNetbeans
net beans revision
special note
sql - part 2 of sample paper
Java netbeans paper1
SQL PRACTICE QUESTIONS 2
SQL Practice Questions
SQL -UNION
SQL INTEGRITY CONSTRAINTS
SQL QUESTION 4
SQL QUESTION 3
JOIN
SQL - QUESTION 2
SQL QUESTION 1
SQL-Groupby Having
SQL- AGGREGATE/MULTIPLE ROW FUNCTION
SQL function- single row
SQL function- single row
SQL Revision XI
DBMS-SQL
► July (2)
► June (1)
Popular Posts About Me
Geetu Sodhi
Output Questions - JavaNetbeans
Follow 12
Identify the possible error(s) in the following code fragment: Underline error(s) and
correct the code. f=1; for(int a=40; (>...
View my complete profile
SQL PRACTICE QUESTIONS 2
In a database create the following tables with suitable constraints :
STUDENTS ...
ASSIGNMENT
ASSIGNMENT Q1) a) What will be the contents of jTextarea1
after executing the following code: 1 ...
QUESTIONS-ch1,2,3
Q UESTIONS: CHAPTER1,2,3 Q1) Which communication
channel(s) is/are suitable in each of the following situations: a. Settin...