43 RÜQİİ, Siyəzən QİS 960037 9900001621 5 2455239 25022
44 RÜQİİ, Sumqayıt QİS 960077 9900001621 6 2455092 43395
45 RÜQİİ, Sumqayıt QİS 960077 9900001621 5 2455092 47185
46 RÜQİİ, Tovuz QİS 960060 9900001621 5 2455240 39237
47 RÜQİİ, Tərtər QİS 960059 9900001621 5 2455240 39244
嗨,大家好。当我从数据库中选择时,它会返回这样的结果。第 7 列是“STATECHANGETIME”,我想编写只返回最后一次更改的 sql(第 7 列的最大值)
我的sql是:
SELECT ORG.DESCRIPTION, ORG.EXTERNALKEY, P.VALUE AS VOEN, AGR.STATECODE, AGR.STATECHANGEDATE, AGR.STATECHANGETIME
FROM organization org, AGREEMENT AGR, PROPERTY P, PMTSVCAGREEMENT PSA
WHERE AGR.RECEIVERID = ORG.ID AND P.ID = ORG.ID AND PSA.ID=AGR.ID
AND P.IDX = 4 AND (org.ownerid = (SELECT id
FROM organization
WHERE externalkey = '960000')
OR ORG.EXTERNALKEY = '960000')
ORDER BY CASE WHEN ORG.EXTERNALKEY = '960000' THEN 0 ELSE 1 END, ORG.DESCRIPTION;
怎么写。感谢你
我希望检索此结果:
43 RÜQİİ, Siyəzən QİS 960037 9900001621 5 2455239 25022
44 RÜQİİ, Sumqayıt QİS 960077 9900001621 5 2455092 47185
45 RÜQİİ, Tovuz QİS 960060 9900001621 5 2455240 39237
46 RÜQİİ, Tərtər QİS 960059 9900001621 5 2455240 39244