On the basis of above given table structures, retrieve the distinct employee ID $(EMPID)$ of all employees of university who are working on project No. $20$, $30$ and $40$.
Solution
We need to retrieve distinct employee IDs.
So, we must use:
SELECT DISTINCT EMPID
Now, the project number can be $20$, $30$ or $40$.
For checking multiple possible values in SQL, we use IN operator.
So, correct condition is:
WHERE PROJNO IN (20,30,40)
Therefore, correct SQL query is:
SELECT DISTINCT EMPID FROM PROJECTWORK WHERE PROJNO IN (20,30,40);
Option (A) is incorrect because PROJNO=(20,30,40) is not valid SQL syntax.
Option (B) is incorrect because it does not use DISTINCT.
Option (D) is incorrect because PROJNO=20,30,40 is not valid SQL syntax.
Correct Answer: (C) SELECT DISTINCT EMPID FROM PROJECTWORK WHERE PROJNO IN (20,30,40);
Online Test Series, Information About Examination, Syllabus, Notification and More.