Welcome to WebmasterWorld Guest from 54.196.233.239

Forum Moderators: open

Message Too Old, No Replies

SQL query.make columns from rows

     

vyhny

10:47 am on Oct 10, 2005 (gmt 0)

10+ Year Member



Hi I need help with one query.
I have following table (simplified):
Name State
--------------
George AAA
George AAA
Thomas AAA
George BBB
Thomas CCC
Thomas DDD
John AAA.

I need to make following table from it:
Name AAA BBB CCC DDD
----------------------------
George 2 1 0 0
Thomas 1 0 1 1
John 1 0 0 0

I'm using MSSQl.
Thank you for any help

aspdaddy

6:42 pm on Oct 10, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hiya, Looks like you need a crosstab. Thats the normal way to transform rows into columns.

For SQL2K, check out the link in msg 8 here:
[webmasterworld.com...]

 

Featured Threads

Hot Threads This Week

Hot Threads This Month