Can we use GROUPING ,GROUPING_ID,Grouping Sets

Database
Enthusiast

Can we use GROUPING ,GROUPING_ID,Grouping Sets

Can some one help me how to use GROUPING ,GROUPING_ID,Grouping Sets in terdata?

2 REPLIES
Enthusiast

Re: Can we use GROUPING ,GROUPING_ID,Grouping Sets

Krishna,

You can go through the below chapter to clear your thoughts about GROUPING SETS:

==>SQL Reference Data Manipulation Statements

====>Chapter: The SELECT Statement

========>GROUPING SETS OPTION

In essence its a way to aggregate data for different groups within the same query.

e.g SELECT DIST_ID , STORE_ID , PROD_ID , SUM(SALES_AMT) FROM SALES_TBL GROUP BY GROUPING SETS ((DIST_ID) , (DIST_ID , STORE_ID) , (DIST_ID m STORE_ID , PROD_ID))

The above case could also be handled using a ROLLUP( GROUP BY ROLLUP(DIST_ID , STORE_ID , PROD_ID)

In a way its UNION of data aggregated on different groups.

Enthusiast

Re: Can we use GROUPING ,GROUPING_ID,Grouping Sets

Thanks mjasrotia