您应该两次加入tableb,一次用于Plumber,另一次用于estimator
select a.ID, a.ID_Name, b1.name plumber, b2.name estimator, a.amount from tableA a inner join tableb b1 on a.id = b1.id and b1.role ='Plumber' inner join tableb b2 on a.id = b2.id and b2.role ='Estimator'
如果有重复的行,则应使用不同的行
select distinct a.ID, a.ID_Name, b1.name plumber, b2.name estimator, a.amount from tableA a inner join tableb b1 on a.id = b1.id and b1.role ='Plumber' inner join tableb b2 on a.id = b2.id and b2.role ='Estimator'