Friday, May 16, 2008

Quer'ng with Cube and RollUp

To summarize data on the table using goup to get data as cube you may use cube and rollup commands.These commands are available in SQL Server 6.5 (and above) and Oracle 8i (and above).....
syntax is like this...

with cube
select tblx.field1,count(*)
from tblx join tblx2
where tblx.price>50
group by tblx.field1 with cube
having count(tblx2.field1)>15;

RollUp
SELECT Type, Store, SUM(Number) as Number
FROM Pets
GROUP BY type,store
WITH ROLLUP

and a nice example usage is at the link

No comments: