
April 3rd, 2005, 06:08 PM
|
|
Registered User
|
|
Join Date: Apr 2005
Posts: 13
Time spent in forums: 2 h 14 m
Reputation Power: 0
|
|
Decode function?
Excuse my newbie question... this might be simple for some of you. I'm working on our intranet site and have a question regarding some basic SQL statements.
I have a table of employees, their IDs, and their manager (along with other info). Some of these employees dont have a manager however (the owner for example). How would I go about displaying all the employees, ID, and their manager's full name? If the employee doesn't have a manager then the field is just blank.
It seems so simple.
Here's what I have, but it's not dynamic. I'd like to rewrite this somehow without hard coding the names:
Code:
select employee_id,full_name,
decode(manager_id,100,'Alex Ruiz',
101,'Michael Gotling',
102,'Harvey Lundgren',
103,'Jon Fellow',
124,'Karen Hatcher',
149,'Bruce Bowler',
201,'Jenny Link',
205,'Lynn Nitzbond',
null)"Manager Full Name"
from emps;
Thank you
|