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: 

Pick out the biggest element from a table with SELECT

Former Member
0 Kudos

Hi,

I have a table with 3 columns. The table looks like the example below. There can be same persons with different dates.

I want to withoud using for loops, just using select statement pick out Emil Larsson with the biggest date, that is the most recent date up to today. How do you achieve this with select statements?

Name LastName Date

John Larsson 20061001

Emil Larsson 20060927

John Larsson 20061006

Emil Larsson 20061018

regards

Baran

1 ACCEPTED SOLUTION

Former Member
0 Kudos

SELECT Name LastName Max(Date) into table itab

from ztable

group by name lastname.

After the execution of the above query you would have the records in internal table itab for each unique name+lastname with the latest date.

Message was edited by: Anurag Bankley

2 REPLIES 2

Former Member
0 Kudos

SELECT Name LastName Max(Date) into table itab

from ztable

group by name lastname.

After the execution of the above query you would have the records in internal table itab for each unique name+lastname with the latest date.

Message was edited by: Anurag Bankley

Former Member
0 Kudos

Hi

SELECT * FROM ZTABLE WHERE NAME = 'EMIL'

AND LASTNAME = 'LARSON'

ORDER BY DATE DESCENDING.

EXIT.

ENDSELECT.

Max