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)
 Converting Rows to Columns

Author  Topic 

malhan
Starting Member

1 Post

Posted - 2006-08-14 : 02:55:17
Hello ppl,
I have written a SQL query that returns data by joining 5-6 tables in following way.

ID Cetificate_name
----------------------------------
335501 Master of Finance
335501 Bachelor Of Finance
335501 Diploma in Finance
335506 MASTER OF APPLIED SCIENCE
335506 BSC Of Applied Scicence
335506 10+2
335514 BACHELOR OF ARCHITECTURE
335514 Master OF ARCHITECTURE
335516 MASTER OF BUSINESS
335516 BACHELOR OF BUSINESS
335518 BE Electonics


But I want data to be returned in following format where rows are converted to columns. Please note that a single person can have n number of qualifications.



ID Cetificate_name1 Cetificate_name2 Cetificate_name2
--------------------------------------------------------------------------------------------
335501 Master of Finance Bachelor Of Finance Diploma in Finance
335506 MASTER OF APPLIED SCIENCE BSC Of Applied Scicence 10+2
335514 BACHELOR OF ARCHITECTURE Master OF ARCHITECTURE Null
335516 MASTER OF BUSINESS BACHELOR OF BUSINESS Null
335518 BE Electonics Null Null

Any ideas??

Regards
Malhan

eyechart
Master Smack Fu Yak Hacker

3575 Posts

Posted - 2006-08-14 : 03:24:11
looks like you are doing a crosstab or pivot. you can search this site for those terms and find many examples of how this can be done.

btw, best way to search sqlteam is to use google. just append your search term with site:sqlteam.com.



-ec
Go to Top of Page
   

- Advertisement -