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 |
|
gustho
Starting Member
2 Posts |
Posted - 2011-02-24 : 22:11:57
|
| Hello Folks,I have a question, I will example with example :Inv# catlcs01 ms010lcs01 mc015lcs01 me025lcs02 md001lcs02 md020lcs02 mc001lcs03 ma020lcs03 mc010The desired result is as follows :Inv# catlcs01 ms010lcs01 mc015lcs01 me025lcs03 ma020lcs03 mc010If the MS010 or ma001 exist, we need to show all the lines related to that inv#. In the above example lcs01 will be shown 3 because Ms010 appears once in that inv series and lcs03 appears 2 times because ma010 appears in the inv series .I hope I have explained this correctly.thanksGus. |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-02-24 : 22:25:24
|
[code]select *from yourtable twhere exists ( select * from yourtable x where x.inv = t.inv and x.cat in ('MS010', 'MA001') )[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-02-26 : 09:34:58
|
quote: Originally posted by khtan
select *from yourtable twhere exists ( select * from yourtable x where x.inv = t.inv and x.cat in ('MS010', 'MA001')) KH[spoiler]Time is always against us[/spoiler]
------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-02-26 : 10:11:06
|
thanks for the correction  KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
gustho
Starting Member
2 Posts |
Posted - 2011-02-26 : 15:28:39
|
Perfect !! Appreciate it.quote: Originally posted by khtan
select *from yourtable twhere exists ( select * from yourtable x where x.inv = t.inv and x.cat in ('MS010', 'MA001') ) KH[spoiler]Time is always against us[/spoiler]
|
 |
|
|
|
|
|