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.
Author |
Topic |
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2006-03-17 : 08:26:22
|
Julio Cesar writes "My English is poor. I hope you can understand me.I have two Tables related each one.TABLE A(ID) (NAME) Cols...01 VALVES02 PIPINGTABLE B(ID) (MODIFIER) (ID_NAME) Cols01 BALL 0102 CHECK 0103 GATE 0104 PIPE COATED 02If I do a SELECT with the two Tables I get the following results.(ID) (NAME) (MODIFIER)01 VALVES BALL01 VALVES CHECK01 VALVES GATE02 PIPING PIPE COATEDMy question is.. Is there any way to format this output to the following?...(ID) (NAME) (MODIFIER_1) (MODIFIER_2) (MODIFIER_3)01 VALVES BALL CHECK GATE02 PIPING PIPE COATEDThanks in advance..." |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-03-17 : 08:34:39
|
[code]select a.ID, a.Name, max(case when b.ID = '01' then b.MODIFIER else '' end) as [MODIFIER_1], max(case when b.ID = '02' then b.MODIFIER else '' end) as [MODIFIER_2], max(case when b.ID = '03' then b.MODIFIER else '' end) as [MODIFIER_3]from TableA a inner join TableB bon a.ID = b.ID_NAMEgroup by a.ID, a.Name[/code] KHChoice is an illusion, created between those with power, and those without.Concordantly, while your first question may be the most pertinent, you may or may not realize it is also the most irrelevant |
|
|
|
|
|