2007 Feb 28 10:19 AM
Hi All,
I have query in which I need the latest record. To get the latest record, I can
1) Select all entries into an internal table and sort them descending and get the first one
2) Select all entries into an internal table and order by in the select statement itself.
Then read the first one.
Which approach should be better as for as the performance is concern.
The query is on MKPF table and I have the material document number. I need the latest entry.
Regards,
Shahu
2007 Feb 28 10:22 AM
ORDER BY is obsolete.
The second approach is better when if you need maximum for each documnt.
you can directly use the
select max * if you need only the maximum of all.
Regards,
Ravi
2007 Feb 28 10:20 AM
Hi
Try SELECT MAX(datum) ... command
Anyways your first option seems fine. Its not the fastest solution, but surely will work.
Regrds
Tamá
2007 Feb 28 10:21 AM
first one because order by in select make your performance decrease.
regards
shiba dutta
2007 Feb 28 10:22 AM
ORDER BY is obsolete.
The second approach is better when if you need maximum for each documnt.
you can directly use the
select max * if you need only the maximum of all.
Regards,
Ravi
2007 Feb 28 10:25 AM
Hi,
The first one would be better.At the most we should not use order by in select statement bcoz it directly sorts the data according to that in database itself reverting performance issues.
Otherwise you can use select max* if records are less.
Reward points if helpful.
Thanks,
Ponraj.s.
2007 Feb 28 11:39 AM