homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderator: open

Databases Forum

SQL query.make columns from rows

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

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)

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:

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved