I have a couple of tsql stored procedures that I'm having problems converting from the pubs example delivered with SqlServer. How do we translate these stored procedures:
CREATEPROCEDURE reptq1 AS
select
case when grouping(pub_id) = 1 then'ALL' else pub_id endas pub_id,
avg(price) as avg_price
from titles
where price isNOTNULL
groupby pub_id with rollup
orderby pub_id
select
case when grouping(type) = 1 then 'ALL' else type end as type,
case when grouping(pub_id) = 1 then 'ALL' else pub_id end as pub_id,
avg(ytd_sales) as avg_ytd_sales
from titles
where pub_id is NOT NULL
group by pub_id, type with rollup
The issue is group by with rollup that's throwing me.