-1
當我對change_management表進行內部連接時,我收到了重複值。它返回三條記錄,但我只想要最近的cmp.id。在SQL INNER JOIN上返回的重複值
SELECT
cmp.id,
cr.id,
coalesce(cmp.effort, 0.00) AS "Effort"
FROM
m_change_request cr
INNER JOIN (select max(id) as id, change_request_fk, effort from m_change_management group by id, change_request_fk, effort) as cmp ON cmp.change_request_fk = cr.id
WHERE
cr.release_fk=509
我需要它通過max(cmd.id)返回最近的記錄。任何想法如何解決這個問題?