Q. In a Database BANK there are two tables with a sample data given below:

Table: EMPLOYEE

ΕΝΟ

ENAME

SALARY

ZONE

AGE

GRADE

DEPT

1.

Mona

70000

East

40

A

10

2.

Muktar

71000

West

45

B

20

3.

Nalini

60000

East

26

A

10

4.

Sanaj

65000

South

36

A

20

5.

Surya

58000

North

30

B

30

Table: DEPARTMENT

DEPT

DNAME

HOD

10

Computers

1

20

Economics

2

30

English

5

 Note.

• ENAME refers to Employee Name
• ADNAME refers to Department Name
• DEPT refers to Department Code
• HOD refers to Employee number (ENO) of the Head

Write SQL queries for the following:


(i) To display ENO, ENAME, SALARY and corresponding DNAME of all the employees whose age is between 25 and 35 (both values inclusive).

(ii) To display DNAME and corresponding ENAME from the tables DEPART- MENT and EMPLOYEE. Hint. HOD of the DEPARTMENT table should be matched with ENO of the EMPLOYEE table for getting the desired result.

(iii) To display ENAME, SALARY, ZONE and INCOME TAX (Note. Income Tax to be calculated as 30% of salary) of all the employees with appropriate column headings.


Answer :-

i = Select ENO, ENAME, SALARY , Dname from Employee , Department where Employee. DEPT = Department. DEPT and age between 25 and 35 ;

ii = Select Dname , Ename from Employee , Department where ENO = HOD ;

iii = Select ENAME, SALARY, ZONE , ( Salary * 0.3 ) as “INCOME TAX” from Employee ;

2 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post