代码语言:javascript复制
select * from (SELECT
min(pgmx.N_Order) pgmx_order,gzjy.C_JYNR
FROM
DB_WXPG.dbo.T_WXPG_PGJG lbpg
LEFT JOIN DB_WXPG.dbo.T_WXPG_PGJG_MX pgmx ON lbpg.C_ID = pgmx.C_PG_JG_ID AND pgmx.C_SFFH = '1'
LEFT JOIN DB_WXPG.dbo.T_WXPG_GZJY gzjy ON pgmx.C_GZJY_ID = gzjy.C_ID
WHERE
lbpg.C_SFYX = '1'
AND lbpg.C_PGLX IN ('1', '2', '5', '6')
AND pgmx.C_GZJY_ID IS NOT NULL
AND lbpg.C_ID = '814CEE6C7B7A636DAC706574C751B1FF'
GROUP BY
gzjy.C_JYNR) t ORDER BY t.pgmx_order
去重前:
去重后:
参考博客: https://blog.csdn.net/qtvb1987/article/details/42081585