Database-Management-System
August 29, 2024Database-Management-System
August 29, 2024Database-Management-System
| Question 266 |
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) and (B) only | |
| (A) and (C) only | |
| (B) only | |
| (C) only |
(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;
(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;
