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 biggest row wich considerations to MAX(date)

Former Member
0 Kudos

Hi,

I want to select the entire row which has the biggest name grouped by name and last.

But the thing is I want to select the entire row because i want to put the entire row into a structure and not just a few fields. In psedocode I want to do:

SELECT * WITH REGARDS TO MAX(Date)

FROM myTable

INTO myTable_Structure

GROUP BY name last.

How do I achieve this?

Name Last Date

Emil Larsson 200609

Emil Larsson 200611

Emil Larsson 200610

1 ACCEPTED SOLUTION

Former Member
0 Kudos

You can try to build a subquery in you select command, haven't tried this one but it could look as follows:

SELECT name lastname date up to 1 rows

INTO myTable_Structure

FROM myTable

where date eq ( select max( date ) from myTable ).

endselect.

4 REPLIES 4

Former Member
0 Kudos

Hi Baran,

u can even do this.

create a table with structure of ur table.

select * from

table

into table ur internal table

if sy-subrc = 0.

sort internal table by Name Last Date

endif.

Madhavi.

Former Member
0 Kudos

Baran,

As I understand it is in continuation of ur prev query...

I would say get the information for namelastnamemax(date) into internal table itab and use the below after that.

SELECT * into table itab1

from ztable

for all enteries in itab

where name = itab-name

and lastname = itab-lastname

and date = itab-date.

Former Member
0 Kudos

Hi

Just as I said in my answer in your previuos post, use ORDER BY option:

SELECT * FROM ZTABLE INTO myTable_Structure

ORDER BY DATE.

Max

Former Member
0 Kudos

You can try to build a subquery in you select command, haven't tried this one but it could look as follows:

SELECT name lastname date up to 1 rows

INTO myTable_Structure

FROM myTable

where date eq ( select max( date ) from myTable ).

endselect.