SELECT c.dept as department, c.name as manager, d.name as name
FROM COMPLEX c
JOIN COMPLEX d ON d.Manager = c.ID
使用上面的自加入查询我得到了这个输出
department | manager | name
-------------------------------------
SW | Ranjan | Deeksha
SW | Ranjan | sham
SW | Ranjan | Junaid
HQ | Vinay | akhilesh
HQ | Vinay | Pranav
但我需要最终输出为:
department | manager | name
------------------------------------
SW | Ranjan | Deeksha
| | sham
| | Junaid
HQ | Vinay | akhilesh
| | Pranav