Skip to Content
author's profile photo Former Member
Former Member

SELECT biggest row wich considerations to MAX(date)

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Oct 20, 2006 at 09:51 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 20, 2006 at 09:13 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 20, 2006 at 09:19 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 20, 2006 at 09:22 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.