count a column, then count the group -oracle reports

You want to the following report output (ProdA and ProdB are within same column):

Prod-Id | A | B | Subtotals
123 | 4  | 3 | 7
124 | 2 | 5 | 7

Columns: prod_id, prod_code, prod_type
Group by: prod_type

  1. After grouping your columns, create formulas for data A, B, All (within group-2):
    [sql]if :prod_code = ‘A’ then –set ‘B’ for second formula
    return 1; –counts 1 on every row of prod_code = ‘A’ (or ‘B’)
    end if;

    if :prod_code is not null then –find all items other than ‘A’ or ‘B’
    return 1; –counts 1 on every row of prod_code = null
    end if;[/sql]

  2. Create a Count for each data type A, B  (within group-1, reset at group-1)
  3. Do a Sum based on the “all items” Count (within group-1, reset at group-1)
  4. Place fields of steps 1,2,3 in a repeating region of group-1

You should have the results as seen in example above.