Monday 21 May 2018

Approx_rank, Approx_sum, Approx_count ( Oracle 18C New Functions)


1. "GROUP BY" clause is mandatory to use approx_* functions.
2. Approx_count & Approx_sum functions has to be used with "HAVING" clause containing approx_rank function.
3. Both approx_* functions and non approx_* aggregate functions are not allowed in same select statement.
4. "ORDER BY" clause within approx_rank function should use only approx_* functions only (+ with "DESC" keyword only).
5. "HAVING" clause should contain "<= number" or "< number" conditions only. Follow this format only ('APPROX_RANK(PARTITION BY ... ORDER BY ... DESC) <(=) n')

SELECT   empno,
         approx_rank ( order by approx_sum(sal) DESC )
FROM     scott.emp
GROUP BY empno
HAVING   approx_rank ( ORDER BY approx_sum(sal) DESC ) <=10
ORDER BY 2;




SELECT   deptno,
         Approx_sum(sal),
         approx_rank ( order by approx_sum(sal) DESC )
FROM     scott.emp
GROUP BY deptno
HAVING   approx_rank ( ORDER BY approx_sum(sal) DESC ) <=10;




SELECT   deptno,
         Approx_count(empno),
         approx_rank ( order by approx_count(empno) DESC )
FROM     scott.emp
GROUP BY deptno
HAVING   approx_rank ( ORDER BY approx_count(empno) DESC ) <=10;


No comments:

Post a Comment

About Me

I am Siva Jeevan.LK [LEARN | CODE | TRAIN | SHARE] Passionate to answer oracle SQL & PLSQL related questions. In my day to day job, I work with technologies including Oracle, Java, Python, MongoDB, talend and UNIX. I am passionate about "DATA", “SQL” , coding & training. In my spare time, I teach database technologies , ETL etc. I am very glad that you are reading my Profile, and I value your time as well as mine. Looking forward to see you in my videos at Siva Academy Passionate to answer oracle SQL & PLSQL related questions. You can contact me via My youtube channel (Siva Academy) or drop an email at siva.k.academy@gmail.com Happy to Learn & Help :-)

Total Pageviews