如何打开以下内容:
username | userLastFirst | email | approver1 |department
FAlbert | Albert, Frankie | abc123@ships.com | Doe, John |HR
FAlbert | Albert, Frankie | abc123@ships.com | Smith, Mike |HR
进入:
username | userLastFirst | email | approver1 |approver2 |department
FAlbert | Albert, Frankie | abc123@ships.com | Doe, John |Smith, Mike |HR
我希望将同一用户的多行及其审批人合并为一个记录,其中包含审批人的列。
如果有两行,可以使用聚合:
select username, userLastFirst, email, min(approver) as approver1 ,
nullif(max(approver), min(approver)) as approver2, department
from t
group by username, userLastFirst, email, department;