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)

Inactive Member
Account Expired


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)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:June 13, 2002
votes: 0

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: