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 |
sebastian11c
Posting Yak Master
129 Posts |
Posted - 2012-05-23 : 17:54:05
|
hi there i have a table called "cars"idcar make line1 audi a42 audi a63 audi s64 audi a85 bmw 3186 bmw 3207 bmw 325i need to do a query , with this resultcolumns ( make , lines ( all the lines with the same make without the line "a4" horizontal)make(varchar) lines (varchar (max))audi a6 s6 a8bmw 318 320 325 many many thanks in advanced,, thank for your help |
|
yosiasz
Master Smack Fu Yak Hacker
1635 Posts |
Posted - 2012-05-23 : 18:25:23
|
Senor SebastianPlease provide DDL and DML<><><><><><><><><><><><><><><><><>If you don't have the passion to help people, you have no passion |
 |
|
yosiasz
Master Smack Fu Yak Hacker
1635 Posts |
Posted - 2012-05-23 : 18:33:35
|
[code]declare @sebastian table(dcar int, make varchar(25), line varchar(25))insert into @sebastianselect 1, 'audi', 'a4'unionselect 2, 'audi', 'a6'unionselect 3, 'audi', 's6'unionselect 4, 'audi', 'a8'unionselect 5, 'bmw', '318'unionselect 6, 'bmw', '320'unionselect 7, 'bmw', '325'select * from @sebastian select make,stuff((select distinct ',[' + line + ']'from @sebastian s2where s2.make = s1.makeAND line <> 'a4'for xml path('')),1,1,'') from @sebastian s1group by make[/code]<><><><><><><><><><><><><><><><><>If you don't have the passion to help people, you have no passion |
 |
|
sebastian11c
Posting Yak Master
129 Posts |
Posted - 2012-05-24 : 09:12:02
|
brilliant code ,,,thank you so much yosiasz thanks for always helping |
 |
|
yosiasz
Master Smack Fu Yak Hacker
1635 Posts |
Posted - 2012-05-24 : 09:33:10
|
denada. learning from great minds right here on this site<><><><><><><><><><><><><><><><><>If you don't have the passion to help people, you have no passion |
 |
|
|
|
|
|
|