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)
 I'm sure this is easy

Author  Topic 

elwoos
Master Smack Fu Yak Hacker

2052 Posts

Posted - 2004-05-10 : 11:11:08
I just can't remember the answer to this though I swear I've seen it somewhere.

I have two tables, lets say TableA and TableF, which both contain the field ID which they can be joined on. TableA has one or more (up to a maximum of about 4) rows for each ID in TableF. I want my results to show all of these values in a single row

so for example

TableF:
ID FNumber
1 a
2 d
3 g

TableA
ID ANumber KCode
1 a1 XX
1 a2 XY
2 a3 XX21
3 a4 XY
3 a5 XX
3 a6 XX13
3 a7 XY13

would produce the following

ID FNumber KCode1 KCode2 KCode3 KCode4
1 a XX XY
2 d XX21
3 g XY XX XX13 XY13

I got part way there but ended up with some duplication. IF anyone can please point me in the right direction I would be very grateful

thanks

steve

Steve no function beer well without

X002548
Not Just a Number

15586 Posts

Posted - 2004-05-10 : 11:20:51


[url]http://www.sqlteam.com/item.asp?ItemID=2368[/url]

Brett

8-)
Go to Top of Page
   

- Advertisement -