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 |
|
rkumar28
Starting Member
49 Posts |
Posted - 2006-01-13 : 18:27:57
|
| Hi,Is there are to pick a row from table. My table has quite a few rows something like below.policy…………..cust_cd…….NameP11234………20…………KingP11234………10………….RonP11234……….00…………BonP22333……….10…………JoyceP22333……….01…………TomI am trying to pick a Name for a policy that corresponds to cust_cd = 20. If for any given policy cust_cd = 20 is not there, I need to pick up a row with cust_cd = 10.I am trying to get this output below:Policy…………..Cust_cd…….NameP11234…………20…………KingP22333……….10….………..JoyceWill appreciate any advice in this regards.ThanksRaj |
|
|
rkumar28
Starting Member
49 Posts |
Posted - 2006-01-13 : 20:44:14
|
| Will appreciate any advice on this....ThanksRaj |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-01-13 : 21:44:26
|
| [code]select *from policy awhere a.cust_cd = '20'union allselect *from policy bwhere b.cust_cd = '10'and not exists (select * from policy x where x.cust_cd = '20' and x.policy = b.policy)[/code]-----------------'KH'if you can't beat them, have someone else to beat them |
 |
|
|
|
|
|