Total Pageviews

May 23, 2017

5/23/2017 06:30:00 AM
Oracle SQLaggregate Functions

Oracle SQL: Aggregate Functions :Group_Id

The GROUP_ID function is used to assign a number to each group that results from a SELECT query clause with a GROUP BY clause.
It’s used to identify any duplicate groups in your output, and works with queries with aggregate functions.
For each unique group that is returned, GROUP_ID will return 0. If a duplicate is found, a value >0 will be returned.


SELECT SUM(sal), deptno, bonus, GROUP_ID()
FROM emp
WHERE bonus > 100
GROUP BY deptno
ROLLUP (deptno, bonus)
HAVING GROUP_ID() < 1;


 
Related Posts Plugin for WordPress, Blogger...