My below query return store_name, Product, count of each product as well count of total product under one account. I want to add one column for store code, but i couldn't. Output look like below : Store_name Store_code Product count Store_1 100 5 abc123 2 abc456 3 Store_2 102 7 bcd123 4 bcd456 3
select case when pt.name is null and a.name is not null then a.Name when pt.name is null and a.name is null then 'Grand Total' else '' end store_name, pt.name SIC, count(*) total from prod p, product_type pt, account a, product_status ps where p.activation_date >= to_date ( '20/SEP/2018 00:00:00', 'DD/MON/YYYY HH24:MI:SS') and p.prod_type in (select id from product_type where prod_id in (123,456,789) and a.id = p.owner and p.status = ps.id and pt.id = p.prod_type group by rollup (a.Name, pt.name)order by a.name, pt.name desc
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)