Reputation:
How do I format the code to have blanks instead of the managers name each time?
Select Manager, Employee From Work
Upvotes: 0
Views: 57
Reputation: 1271091
There is no easy way to do this, because this type of processing is not really suitable for relational databases. Why? The result set depends entirely on ordering -- and SQL works with unsorted sets.
It is possible. Here is one method:
select (case when employee is null then manager end) as manager,
employee
from ((select distinct manager, NULL as employee from work) union all
(select manager, employee from work)
) me
order by manager, (case when employee is null then 1 else 2 end), employee;
However, I advise you to do this in the application layer rather than the database.
Upvotes: 2