hi gruby.lilo,
May I help you if you sent your samle. because I did it :)
I m sending a sample for you. I hope it be helpfull for you.
VI
***************
use pubs
--select * from sales
select
GROUPING(datepart(yy,ord_date)) ,
datepart(yy,ord_date), --sadece buna ait diptoplamları alalım
stor_id,
payterms,
sum(qty),
count(qty)
from sales
group by
datepart(yy,ord_date), stor_id, payterms
with rollup
having
1 = case
when GROUPING(datepart(yy,ord_date)) = 0 and ( GROUPING(stor_id) = 0 and GROUPING(payterms) = 0 ) then 1
when GROUPING(datepart(yy,ord_date)) = 1 then 1
else 0 end
order by
GROUPING(datepart(yy,ord_date)) ,
datepart(yy,ord_date)
Veysel Ispir
Istanbul TUR