I want to extract the “last” inserted record from database, using this type of query
SELECT A.IDOC_NUM, A.SEG_NUM
FROM AGR3PL_LINE A, AGR3PL_IDOC B
WHERE A.IDOC_NUM(+) = B.IDOC_NUM
AND B.IDOC_NUM = '457154' AND B.CREATION_DATE = (SELECT MAX(B.CREATION_DATE) FROM AGR3PL_IDOC B)
ORDER BY A.SEG_NUM DESC;
The result is this:
IDOC_NUM SEG_NUM
457154 9
457154 8
457154 7
457154 6
457154 5
457154 4
457154 3
457154 2
457154 10
457154 1
This is correct, but the entry 10 is last entered, but as you can see the format result is not good, it sholud be 10,9,8…, is it maybe problem with datebase or somethig else???
1 Answer