Application Development and Automation 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: 
Read only

Row having higher date.

Former Member
0 Likes
955

hi.

am fetching data from a table where threr are 4 rows having same values in each column, only date in each row is different. I have to select only row which has higher date.How can i do this??

5 REPLIES 5
Read only

Former Member
0 Likes
910

select max(date)

field1

field2

from <table>

into wa_table

where <where condition>.

another example:

<i><b>DATA: name TYPE scustom-name,

postcode TYPE scustom-postcode,

city TYPE scustom-city,

max TYPE sbook-loccuram.

SELECT scustomname scustompostcode scustom~city

MAX( sbook~loccuram )

INTO (name, postcode, city, max)

FROM scustom INNER JOIN sbook

ON scustomid = sbookcustomid

WHERE sbook~fldate BETWEEN '20010101' AND '20011231' AND

sbook~carrid = 'LH ' AND

sbook~connid = '0400'

GROUP BY scustomname scustompostcode scustom~city

ORDER BY scustom~name.

WRITE: / name, postcode, city, max.

ENDSELECT.</b></i>

Regards,

Ravi

Read only

Former Member
0 Likes
910

Use select Max(date) ......into table itab etc.

hope it works.

cheers.

santosh

Read only

Former Member
0 Likes
910

SELECT SINGLE F1 F2 ... MAX( DATE ) FROM TABLE INTO WA_ITAB.

Read only

Former Member
0 Likes
910

HI,

You can use aggregate function MAX.

select max(date_fld) from table into v_maxdate.

if sy-subrc = 0.

select * from table where date_fld = v_maxdate.

endif.

Regards,

Sailaja.

Read only

Former Member
0 Likes
910

Hi,

Select all the dates into an internal table, sort the internal table on Date field descending, this will get the max.date value on top, the rest can be deleted from the internal table using delete statement using index numbers,

Hope this helps,

Rgds,