Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

SQL query.make columns from rows



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:
George 2 1 0 0
Thomas 1 0 1 1
John 1 0 0 0

I'm using MSSQl.
Thank you for any help


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:


Featured Threads

Hot Threads This Week

Hot Threads This Month