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)
 Matrix Query

Author  Topic 

hnomani
Starting Member

35 Posts

Posted - 2005-07-11 : 12:00:06
Is there a way to display the results from a query in a matrix format (like variable columns and rows displayed in reporting tools like MS Reporting Services) in SQL Server 2000?

Example:

use pubs
go

select stor_id, left(convert(varchar(8), ord_date, 112), 6) as ord_month, sum(qty) as qty
from sales
group by stor_id, left(convert(varchar(8), ord_date, 112), 6)
go

The results should have stor_id as the first column and each value of the ord_month as the other columns and the qty value corresponding to each stor_id and ord_month.

Thanks

Kristen
Test

22859 Posts

Posted - 2005-07-11 : 13:12:13
You after a Cross Tab? There are several articles on SQL Team about that - try searching for "CROSS TAB" or "PIVOT TABLE"

Kristen
Go to Top of Page

hnomani
Starting Member

35 Posts

Posted - 2005-07-11 : 15:30:03
Thanks,

I found an article on Dynamic Cross-Tabs/Pivot Tables that explains how to work on these kinds of queries.

http://www.sqlteam.com/item.asp?ItemID=2955
Go to Top of Page
   

- Advertisement -