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
 SQL Server Development (2000)
 Put matching fields into one row

Author  Topic 

Cowboy
Yak Posting Veteran

72 Posts

Posted - 2008-11-13 : 04:47:38
Hi all,

I have a table that has mutliple rows with the same id's but different date values. When there is an id on multiple rows I want to put it on one row with the dates in different columns if thats possible.

for example:

id date
1 10/12/1899
2 10/12/1900
2 10/12/1901
3 10/12/1905
3 10/12/1905
3 10/12/1905

would be arranged:

id date1 date2 date3
1 10/12/1899 null null
2 10/12/1900 10/12/1901 null
3 10/12/1905 10/12/1905 10/12/1905

thanks
W

I want to build a spaceship with ligthspeed capabilities and I don't even know what a wrench is.

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2008-11-13 : 05:53:38
search around here for Pivot or Cross Tabs.

_______________________________________________
Causing trouble since 1980
Blog: http://weblogs.sqlteam.com/mladenp
Speed up SSMS development: www.ssmstoolspack.com <- version 1.1 out!
Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2008-11-13 : 06:03:10
Check the FAQ -- this is one of the most frequently asked questions.

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=55210

There are some good articles on doing this in 2000 (there are additional operators that make this a bit easier in 2005)


Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page

Cowboy
Yak Posting Veteran

72 Posts

Posted - 2008-11-13 : 06:13:24
Thanks I'll have a look at the FAQs, just needed a point in the right direction appreciated!


I want to build a spaceship with ligthspeed capabilities and I don't even know what a wrench is.
Go to Top of Page

Cowboy
Yak Posting Veteran

72 Posts

Posted - 2008-11-13 : 06:15:16
What should I be looking for in the FAQ?

I want to build a spaceship with ligthspeed capabilities and I don't even know what a wrench is.
Go to Top of Page

Cowboy
Yak Posting Veteran

72 Posts

Posted - 2008-11-13 : 06:17:48
Got it:

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=56058

I want to build a spaceship with ligthspeed capabilities and I don't even know what a wrench is.
Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2008-11-13 : 06:28:23
I was more thinking of the Links:::

http://weblogs.sqlteam.com/jeffs/archive/2005/05/02/4842.aspx

and

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=6216

actually.


Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page
   

- Advertisement -