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 |
|
kwikwisi
Constraint Violating Yak Guru
283 Posts |
Posted - 2010-04-01 : 03:06:06
|
| I want to select records where col1=@val1 [records should have different col2 or col3 with same col1 ]Eg.col1 col2 col3111 aa s1111 aa s2111 bb s1tks. |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-04-01 : 03:30:44
|
what is the expected result ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
kwikwisi
Constraint Violating Yak Guru
283 Posts |
Posted - 2010-04-01 : 03:39:35
|
| Below is the expected result col1 col2 col3111 aa s1111 aa s2111 bb s1Out ofcol1 col2 col3111 aa s1111 aa s2111 bb s1111 aa s1111 bb s1 |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-04-01 : 03:45:47
|
Then you can use group by.select col1,col2,col3from tablegroup by col1,col2,col3 No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
kwikwisi
Constraint Violating Yak Guru
283 Posts |
Posted - 2010-04-01 : 03:48:36
|
| I also have other cols to be selected. |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-04-01 : 03:59:20
|
quote: Originally posted by kwikwisi I also have other cols to be selected.
then add it to the select and group by listif this is not what you are after, perhaps you should take one step back and explain your situation and requirement KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|