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
 Transact-SQL (2000)
 Crosstab effect? - Sort of...

Author  Topic 

mem
Starting Member

28 Posts

Posted - 2004-10-13 : 21:22:25
Hello,

Let's say I have a simple select...

select col1 as 'header4col1', col2 as 'header4col2', col3 as 'header4col3'

Let's say the result ONLY produces one row, then we should get...

header4col1 | header4col2 | header4col3
========================================
col1value | col2value | col3value

Ok, I'd like to produce this result instead...

newcol1 | newcol2
==========================
header4col1 | col1value
header4col2 | col2value
header4col2 | col3value

Why and what for?...

Well, I'm displaying this information in a table. The table has two columns. One for the 'category name' and the other shows the summary results. I'd like to create the 'category name' in sql instead of in the ASP code. Also, I wanted to prevent the current formatting I'm doing to get the above result.

Help needed, thanks.

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2004-10-13 : 22:25:53
select 'header4col1', col1
Union
Select 'header4col2', col2
Union
Select 'header4col3', col3

Corey
Go to Top of Page

Richard Branson
Yak Posting Veteran

84 Posts

Posted - 2004-10-14 : 05:50:14
Robvolk has an excellent article on Crosstabs at:
http://www.sqlteam.com/item.asp?ItemID=2955

You can't teach an old mouse new clicks.
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2004-10-14 : 09:13:19
This is the opposite of a cross tab, Rob's procedure doesn't help in this case.


- Jeff
Go to Top of Page

Richard Branson
Yak Posting Veteran

84 Posts

Posted - 2004-10-14 : 12:46:50
Oops, My bad...

You can't teach an old mouse new clicks.
Go to Top of Page
   

- Advertisement -