SELECT
o. ID AS ID,
( CASE
WHEN q.uniscid = o.uniscid THEN
q.uniscid ELSE
NULL
END
) AS uniscid,
( CASE
WHEN q.regno = o.regno THEN
q.regno ELSE
NULL
END
) AS regno,
( CASE
WHEN q.entname = o.entname THEN
q.entname ELSE
NULL
END
) AS entnameFROM
data_syfr_tem oLEFT JOIN data_qyfr q ON (
o.entname = q.entname OR o.uniscid = q.uniscid OR o.regno = q.regno
)WHERE
o.batchno = '20171213-2'AND STATE = '1';我想把下面的两个id合并了 变成 6077 1211 null 测试单位名称,有大哥能教教吗。。。DISTINCT on (o.id)我加了这个的话,数据就变成前两行的数据了,并合并成我想要的这个样子
1 回答
当年话下
TA贡献1890条经验 获得超9个赞
SELECT o. ID AS ID, ( SELECT uniscid FROM data_qyfr WHERE uniscid = o.uniscid ) AS uniscid, ( SELECT regno FROM data_qyfr WHERE o.regno = q.regno ) AS regno, ( SELECT entname FROM data_qyfr WHERE o.entname=entname ) AS entnameFROM data_syfr_tem oWHERE o.batchno = '20171213-2'AND STATE = '1';
添加回答
举报
0/150
提交
取消