【发布时间】:2017-12-18 08:09:47
【问题描述】:
数据是从两个具有一对可能关系的表中提取的。
查询:
select temp1.code, temp1.name, temp_dt.item_type,
(select item_name from pr_payroll_item where xid = temp_dt.payroll_item_xid
),
temp_dt.amount from pr_template temp1, pr_template_detail temp_dt
where temp1.xid = temp_dt.parent_xid;
Item Type
0 ear
1 add
2 ded
我必须这样显示数据
code name ear value add value ded value
001 Nav BASIC 1000.00 HR 600.00 PF 50.00
FUEL 200.00
Mobile 300.00
其他名称“我”与 mh01 相同 我怎样才能在 Postgres 中做到这一点?实现这个结果集的查询应该是什么。
【问题讨论】:
标签: sql postgresql pivot crosstab