Why are these 2 queries giving different outputs?

Query no 1:-

SELECT COUNT(ENAME)
FROM EMP
WHERE 
 JOB IN 'MANAGER' 
 OR JOB IN 'ANALYST' 
 AND SAL IN (
    SELECT SAL + NVL (COMM,0)
    FROM EMP
    WHERE SAL LIKE '%0')
GROUP BY JOB;

The Query 1 gives me the following output:-

COUNT(ENAME)
------------
           3
           2

Query no 2:-

 SELECT COUNT(ENAME)
 FROM EMP
 WHERE 
   JOB = ANY (
       SELECT JOB
       FROM EMP
       WHERE JOB IN ('MANAGER', 'ANALYST') 
     )
   AND SAL IN (
       SELECT SAL + NVL (COMM,0)
       FROM EMP
       WHERE SAL LIKE '%0'
     )
 GROUP BY JOB;

The Query 2 gives me the following output:-

COUNT(ENAME)
------------
           2
           2


Comments

Popular posts from this blog

Today Walkin 14th-Sept

Hibernate Search - Elasticsearch with JSON manipulation

Spring Elasticsearch Operations