Suppose we have a table SALES with the following columns:cust_namesales_person_namesale_amt
then the SQL command:
SELECT cust_name c , sales_person_name s , SUM(sale_amt) , GROUPING(c , s) grpFROM SALESGROUP BY CUBE(c,s)ORDER BY grp;
will fail. But,
SELECT cust_name c , sales_person_name s , SUM(sale_amt) , GROUPING( cust_name , sales_person_name) grpFROM SALESGROUP BY CUBE(c,s)ORDER BY grp;
will succeed.
Why is it illegal to use the column aliases in the GROUPING function?