select temp.工号,
(select 金额 from 工资表 where 工资表.工号 = temp.工号 and 工资表.工资项目 = '基本工资') as 基本工资,
(select 金额 from 工资表 where 工资表.工号 = temp.工号 and 工资表.工资项目 = '岗位工资') as 岗位工资,
(select 金额 from 工资表 where 工资表.工号 = temp.工号 and 工资表.工资项目 = '加班工资') as 加班工资,
(select 金额 from 工资表 where 工资表.工号 = temp.工号 and 工资表.工资项目 = '夜班费') as 夜班费,
(select 金额 from 工资表 where 工资表.工号 = temp.工号 and 工资表.工资项目 = '养老金') as 养老金,
(select 金额 from 工资表 where 工资表.工号 = temp.工号 and 工资表.工资项目 = '公积金') as 公积金
from
(select distinct 工号 from 工资表) as temp