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 |
|
baze7
Yak Posting Veteran
58 Posts |
Posted - 2010-02-09 : 17:58:09
|
| I am doing the following, my question is, if there is no match for EM.emp_num = SM.ref_num, how can I return the value of slsman.slsman instead? inner join( select distinct slsman.slsman,slsman.ref_num from slsman group by slsman,ref_num) as SM on SM.slsman = co.slsman left outer join( select distinct employee.emp_num,employee.name from employee group by emp_num,name) as EM on EM.emp_num = SM.ref_numThanksChad |
|
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2010-02-09 : 18:27:32
|
| Are you trying to return a value from the Employee table but have it default to the salesman if no employee is found? If so, you can COALESCE the employee name:select coalesce(em.emp_num, sm.ref_num) as emp_num, coalesce(em.name, sm.slsman) as namefrom ...=======================================Few things are harder to put up with than the annoyance of a good example. (Mark Twain) |
 |
|
|
|
|
|