Directions (Q96–100): A university database has the tables EMPLOYEE (EID, NAME, SALARY, DEPTNO, HODEID …; PRIMARY KEY EID; HODEID references EMPLOYEE(EID); DEPTNO references DEPARTMENT(DID)), DEPARTMENT (DID, DNAME, HODID; PRIMARY KEY DID; UNIQUE DNAME; HODID references EMPLOYEE(EID)) and PROJECTWORK (EMPID, PROJNO; PRIMARY KEY (EMPID, PROJNO); EMPID references EMPLOYEE(EID)).
Which of the following query/queries
return the employee ID and name of
employees whose salary is greater thanthe salary of all employees in department number 20 of university? Order results by employee ID (refer to table structures given above).
(A) SELECT EID, NAME FROM EMPLOYEE WHERE SALARY>(SELECT SALARY FROM EMPLOYEE WHERE DEPTNO=20)
ORDER BY EID;
(B) SELECT EID, NAME
FROM EMPLOYEE WHERE SALARY>
(SELECT SALARY FROM EMPLOYEE
WHERE DEPTNO =20 );
(C) SELECT EID, NAME
FROM EMPLOYEE
WHERE SALARY>ALL(SELECT SALARY
FROM EMPLOYEE WHERE DEPTNO =20)
ORDER BY EID
Pick an option to check yourself, or open the answer below.
Show answer & explanation
Correct answer: D. (C) only
Explanation
A plain > comparison with a subquery that returns many rows is an error, so A and B fail. > ALL (subquery) compares with every department-20 salary, and C also orders by EID.
More Database Management Systems questions
- In reference to the above given table structures, which of the following query/queries will drop the 'SALARY' column from 'EMPLOYEE' table?…
- Refer table, structures given above. The university decided to give all employees in the 'SCIENCE' department a 20% rise in salary. Which o…
- Which of the component module of DBMS does rearrangement and possible ordering of operations, eliminate redundancy in query and use efficie…
- Given two tables R1(x,y) and R2(y,z) with 50 and 30 numbers of tuples respectively. Find the maximum number of tuples in the output of natu…
- Given two tables EMPLOYEE (EID, ENAME, DEPTNO) DEPARTMENT (DEPTNO, DEPTNAME) Find the most appropriate statement of the given query : Selec…
- Find the minimum number of tables required for converting the following entity relationship diagram into a relational database.