...
Database-Management-System
August 29, 2024
Database-Management-System
August 29, 2024
Database-Management-System
August 29, 2024
Database-Management-System
August 29, 2024

Database-Management-System

Question 266
Comprehension:

Consider the following table structures related to a university for Q96 to Q100:-

EMPLOYEE

         NAME          VARCHAR (30)         NOT NULL,

         EID               VARCHAR (10)        NOT NULL,

         DEPTNO      INT (5)                      NOT NULL,

         HODEID       VARCHAR (10),  

         SALARY       INT (10), 

PRIMARY KEY (EID),

FOREIGN KEY (HODEID) REFERENCES EMPLOYEE (EID),

FOREIGN KEY (DEPTNO) REFERENCES DEPARTMENT (DID);

DEPARTMENT

       DID                INT (5)                    NOT NULL,

       DNAME         VARCHAR (30)       NOT NULL,

       HODID           VARCHAR (10)      NOT NULL,

       HODNAME    VARCHAR (30),

PRIMARY KEY (DID),

UNIQUE (DANAME),

FOREIGN KEY (HODID) REFERENCES EMPLOYEE (EID);

PROJECT WORK:

        EMPID                  VARCHAR (30)          NOT NULL,

        PROJNO              INT (5)                        NOT NULL,

        PROJECTLOC     VARCHAR (30)          NOT NULL,

PRIMARY KEY (EMPID, PROJNO),

FOREIGN KEY (EMPID) REFERENCES EMPLOYEE (EID),
SubQuestion No: 99

Q99: Which of the following query/ queries return the employee ID and name of employees whose salary is greater than the salary of all employees in department number 20 of university. Order result by employee ID (refer 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

Choose the correct answer from the options given below:

A
(A) and (B) only
B
(A) and (C) only
C
(B) only
D
(C) only
Question 266 Explanation: 

(A): mysql> where salary>(select salary from employee where deptno=2) order by eid;

ERROR : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘where salary>(select salary from employee where deptno=2) order by eid’ at line 1

(B): mysql> select eid,name from employee

-> where salary>(select salary from employee where deptno=2);

ERROR : Subquery returns more than 1 row

(C): mysql> select eid,name from employee

-> where salary>all(select salary from employee where deptno=2) order by eid;
Correct Answer: D
Question 266 Explanation: 

(A): mysql> where salary>(select salary from employee where deptno=2) order by eid;

ERROR : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘where salary>(select salary from employee where deptno=2) order by eid’ at line 1

(B): mysql> select eid,name from employee

-> where salary>(select salary from employee where deptno=2);

ERROR : Subquery returns more than 1 row

(C): mysql> select eid,name from employee

-> where salary>all(select salary from employee where deptno=2) order by eid;

Leave a Reply

Your email address will not be published. Required fields are marked *