karlomutschler
Programmer
Hi,
this query should only deliver the record with the highest sequence number, but does not.
SELECT *
FROM con_status_history csh1
INNER JOIN con_status_history csh2 ON csh1.contract_id = csh2.contract_id
AND (csh2.contract_id, csh2.seqno) IN
(SELECT csh3.contract_id, max(csh3.seqno)
FROM con_status_history csh3
GROUP BY csh3.contract_id)
WHERE csh1.contract_id = 2117431
Result:
CONTRACT_ID SEQNO REQUEST_DATE
2117431 4 2001-06-15
2117431 3 2001-06-06
2117431 2 2001-03-30
2117431 1 2001-03-24
TIA
Kind regards
Karlo
this query should only deliver the record with the highest sequence number, but does not.
SELECT *
FROM con_status_history csh1
INNER JOIN con_status_history csh2 ON csh1.contract_id = csh2.contract_id
AND (csh2.contract_id, csh2.seqno) IN
(SELECT csh3.contract_id, max(csh3.seqno)
FROM con_status_history csh3
GROUP BY csh3.contract_id)
WHERE csh1.contract_id = 2117431
Result:
CONTRACT_ID SEQNO REQUEST_DATE
2117431 4 2001-06-15
2117431 3 2001-06-06
2117431 2 2001-03-30
2117431 1 2001-03-24
TIA
Kind regards
Karlo