2006 Aug 16 11:10 AM
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??
2006 Aug 16 11:11 AM
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
2006 Aug 16 11:13 AM
Use select Max(date) ......into table itab etc.
hope it works.
cheers.
santosh
2006 Aug 16 11:14 AM
2006 Aug 16 11:15 AM
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.
2006 Aug 16 11:16 AM
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,
| User | Count |
|---|---|
| 8 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |