Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Crosstab Row Summary

Author  Topic 

Glenn Espie
Starting Member

2 Posts

Posted - 2002-10-30 : 09:49:05
Has anyone modified / attempted to modify the crosstab sp posted in this forum to produce row summaries.

Is it possible?

I need to produce a row average. Any pointers would be very helpful.

Glenn

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-10-30 : 09:54:34
The second example in the article shows a row sum and a row count:

EXECUTE crosstab 'select pub_name, count(qty) as orders, sum(qty) as total
from sales inner join titles on (sales.title_id=titles.title_id)
right join publishers on (publishers.pub_id=titles.pub_id)
group by pub_name', 'sum(qty)','type','titles'


You can easily change that to an AVG() or any other aggregate function.

Go to Top of Page

Glenn Espie
Starting Member

2 Posts

Posted - 2002-10-30 : 10:17:48
Many thanks

Glenn

quote:

The second example in the article shows a row sum and a row count:

EXECUTE crosstab 'select pub_name, count(qty) as orders, sum(qty) as total
from sales inner join titles on (sales.title_id=titles.title_id)
right join publishers on (publishers.pub_id=titles.pub_id)
group by pub_name', 'sum(qty)','type','titles'


You can easily change that to an AVG() or any other aggregate function.





Go to Top of Page
   

- Advertisement -