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)
 Select statement Output to a single row

Author  Topic 

neelutyagi
Starting Member

3 Posts

Posted - 2008-04-29 : 10:59:33
I want to display top 3 instance group by contactid per row..
Dont know how to do that..

For eg:
COntact_ID, Instance_ID
1 5
1 6
1 4
1 2
1 3
2 5
2 2
2 3
2 4
3 5
3 4


The result I was expecting to get

Contact_id Inst_Id1 Inst_id2 Inst_id3
1 5 6 4
2 5 2 3
3 5 4


I would appreciat if anyone can help ont this

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2008-04-29 : 11:03:12
search for pivot around here

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-04-29 : 11:03:15
Using SQL Server 2005?



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2008-04-29 : 11:04:02
moved from Database Design and Application Architecture

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com
Go to Top of Page

neelutyagi
Starting Member

3 Posts

Posted - 2008-04-29 : 11:07:42
its sql server 2000
Go to Top of Page

neelutyagi
Starting Member

3 Posts

Posted - 2008-04-29 : 11:08:11
Want to write the query in sql server 2000..
Go to Top of Page

cat_jesus
Aged Yak Warrior

547 Posts

Posted - 2008-04-29 : 14:47:44
Do a search for pivot in this forum and you will find your answer.



An infinite universe is the ultimate cartesian product.
Go to Top of Page
   

- Advertisement -