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
答案 0 :(得分:0)
如果没有更多信息,我猜this code可以帮助您。它按降序排列STATECHANGEDATE, STATECHANGETIME
排序,然后使用
WHERE ROWNUM <= 1
希望它有所帮助。