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 |
|
imranabdulaziz
Yak Posting Veteran
83 Posts |
Posted - 2009-08-22 : 07:26:09
|
| Dear all,I am using sql server 2005.EMPCODE EMPNAME BOSSCODE XYZ XYZEM001 ABC EM005 EM002 DEF EM011 EM005 XYZ EM011 EM011 LCD I want to display empcode , empname , bossname likeEm001 abc xyzI tried with this query SELECT ER_EMP_CODE , ER_EMP_NAME , (SELECT ER_EMP_NAME FROM emp_DTL WHERE ER_EMP_CODE = A.ER_BOSS_CODE ) FROM emp_DTL AI got the correct result but is there any other way around to achieve the required result |
|
|
cat_jesus
Aged Yak Warrior
547 Posts |
Posted - 2009-08-22 : 08:47:33
|
| select A.empcode, A.empname, coalesce(B.empname,'No Boss!')From sometable Aleft join sometable b on A.bosscode = B.EmpcodeLike this?An infinite universe is the ultimate cartesian product. |
 |
|
|
|
|
|