title: Oracle - GROUPING_ID with GROUPING SETS
body: <p>I would like to verify my understanding based on an example as this will be used for constructing an equivalent query for my project. This is an example quoted from <a href="https://oracle-base.com/articles/misc/rollup-cube-grouping-functions-and-grouping-sets#grouping_sets" rel="nofollow">https://oracle-base.com/articles/misc/rollup-cube-grouping-functions-and-grouping-sets#grouping_sets</a></p>
  
  <pre><code>SELECT fact_1_id,
         fact_2_id,
         fact_3_id,
         SUM(sales_value) AS sales_value,
         GROUPING_ID(fact_1_id, fact_2_id, fact_3_id) AS grouping_id
  FROM   dimension_tab
  GROUP BY GROUPING SETS((fact_1_id, fact_2_id), (fact_1_id, fact_3_id))
  ORDER BY fact_1_id, fact_2_id, fact_3_id;
  </code></pre>
  
  <p>Based on the query above, </p>
  
  <ol>
  <li><p>Can I say that there will be two subtototals, with the first being group by <code>FACT_1_ID, FACT_2_ID</code> and the other group by <code>FACT_1_ID, FACT_3_ID</code>?</p></li>
  <li><p>The <code>GROUPING_ID</code> for 1 refers to group by <code>FACT_1_ID, FACT_2_ID</code>? Whereas the <code>GROUPING_ID</code> for 2 refers to group by <code>FACT_1_ID, FACT_3_ID</code>?</p></li>
  <li><p>In continuation from point 2. Since <code>GROUPING_ID</code> for 1 refers to group by <code>FACT_1_ID, FACT_2_ID</code>, hence the column <code>FACT_3_ID</code>  remains <code>NULL</code> as it's not being used as the <code>GROUP BY</code> clause.</p></li>
  </ol>
  
  <p>Is my understanding correct?</p>