This is tricky but most common question in Interviews. Popular question on employee table.

EMP => I am using only one table

Query:

[code language=”sql”]
SELECT COUNT(E.EMPID)
FROM EMP E, EMP D
WHERE E.WORKDEPT=D.WORKDEPT
[/code]

RESULT: 298 , WE GOT COUNT OF EMPLOYEES

IF we know dept and emp tables ( 2 Tables)

[code language=”sql”]
SELECT COUNT(E.EMPID)
FROM EMP E, DEPT D
WHERE E.WORKDEPT=D.DEPT
[/code]

RESULT: 298 , WE GOT COUNT OF EMPLOYEES

Fediverse reactions

Discover more from Srinimf

Subscribe now to keep reading and get access to the full archive.

Continue reading