Rollup data from one table to a different level logic question

Database

Rollup data from one table to a different level logic question

I have data in a table rolled up to a Group Id level. However, I need to report on it at at a cost and volumn level as it relates to a product code. I am trying to understand how to orient the logic to do this task.

I have written the code BASICALLY as below:

SELECT DISTINCT

  TRIM(PRODUCT_CD)||_||TRIM(PRIORITY_CD),

  VOLUMN_CNT,

  VOLUMN_PCT

FROM

  TABLE_1,

  TABLE_2

WHERE

  JOIN CONDTIONS

  FILTER CONDITIONS

ORDER BY

  1,2,3,4

I need the data to rollup as a total for the first row in the select condition, but it is not doing that obviously. I just need a bump to my thinking to understand how I can do this task. I need a sinlge row for each "product_cd||priority_cd" without getting an error for a non-agragation not being part of the set error.

Thanks

Tags (1)