Join the OracleApps88 Telegram group @OracleApps88to get more information on Oracle EBS R12/Oracle Fusion applications.

If you are facing any issues while copying the Code/Script or any issues with Posts, Please send a mail to OracleApp88@Yahoo.com or message me at @apps88 or +91 905 957 4321 in telegram.

Wednesday, October 23, 2013

Sub queries in Having Clause oracle




SELECT Deptno, MIN(Sal)
FROM Emp
GROUP BY Deptno
HAVING  MIN(Sal) > (SELECT
                    MIN(Sal)
                    FROM Emp
                    WHERE  Deptno = 20);
                   
SELECT Job, AVG(Sal)
FROM Emp
GROUP BY Job
HAVING AVG(Sal) =  (SELECT
                    MIN(Avg(Sal))
                    FROM Emp
                    GROUP BY Job);

SELECT Job, AVG(Sal)
FROM Emp
GROUP BY Job
HAVING AVG(Sal) < (SELECT
                    MAX(AVG(Sal))
                    FROM Emp
                    GROUP BY Job);

SELECT Job, AVG(Sal),
TO_CHAR(AVG (Sal), 'L99,999.99')
FROM Emp
GROUP BY Job
HAVING  AVG(Sal) < (SELECT
MAX(AVG(Sal))
FROM Emp
GROUP BY Deptno);  

No comments:

Post a Comment

If you are facing any issues while copying the Code/Script or any issues with Posts, Please send a mail to OracleApp88@Yahoo.com or message me at @apps88 or +91 905 957 4321 in telegram.
Best Blogger TipsGet Flower Effect