如图所示,想法是不要在“主管”列中重复相同的值。
select e.Name as Employee, s.Name as Supervisor
from Employee e, Employee s
where e.Employee_Supervisor = 2 and s.id = 2
答案 0 :(得分:1)
如评论中所述,这可能应该由表示层来完成,但是。 。
select
e.Name AS Employee,
case when row_number() over (partition by s.Name order by e.Name)=1
then s.Name else '' end AS Supervisor
from Employee e, Employee s
where e.Employee_Supervisor=2 AND s.id=2