Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

select date which is latest

Former Member
0 Kudos

Hi ,

I am trying to pick a field from a database table based on the date...

I should select "the latest day in the past from today "...How do I write the select statement?

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Select all records into a table and then sort the table on date <descending>. Read this table with index 1. This will give you the latest record.

OR

Use order by clause on date field <descending>.

Hope it helps.

Lokesh

4 REPLIES 4

Former Member
0 Kudos

Select all records into a table and then sort the table on date <descending>. Read this table with index 1. This will give you the latest record.

OR

Use order by clause on date field <descending>.

Hope it helps.

Lokesh

ferry_lianto
Active Contributor
0 Kudos

Hi,

You can use SELECT ... UP TO 1 ROWS statement with ORDER BY <date field> DESCENDING option.

Regards,

Ferry Lianto

Former Member
0 Kudos

SELECT single * FROM <dbtable> WHERE region = 'R1'

ORDER BY DATE DESCENDING.

this is possible......

but it is not good performancewsie....

so select into internal table....sort by date descending and use it.....!!!!

Former Member
0 Kudos

Hi ramana,

Check this..


SELECT * FROM <tab> WHERE matnr EQ 'ABCD'
                         ORDER BY updat DESCENDING.
ENDSELECT.

Ooooops ...I'm too late

Message was edited by:

Sudhakar G