Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
The max value of a given group
Message
From
17/03/2004 11:57:54
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00887108
Message ID:
00887129
Views:
11
This message has been marked as a message which has helped to the initial question of the thread.
>Hi all, I have a table with the following fields: Family, name, age and level. In this table a family can have several members and I need a SQL statement that gets me the older member of each family order by level. For example:
>
>
>Family  Name      Age    Level
>--------------------------------
>01      xxxxxxxx   15      1
>01      xxxxxxxx   13      1
>01      xxxxxxxx   17      2
>02      xxxxxxxx   12      1
>02      xxxxxxxx   15      1
>02      xxxxxxxx   13      1
>03      xxxxxxxx   13      1
>03      xxxxxxxx   18      2
>03      xxxxxxxx   12      1
>
>
>
>The result should be:
>
>
>Family  Name      Age    Level
>--------------------------------
>01      xxxxxxxx   15      1
>02      xxxxxxxx   15      1
>03      xxxxxxxx   13      1
>01      xxxxxxxx   17      2
>03      xxxxxxxx   18      2
>
>
>
>Any help is greatly appreciated!
>
>Enmanuel
select * from myTable A ;
 where Age = ;
 (select max(age) from myTable B ;
     where a.Family = b.Family and a.Level = b.Level) ;
     order by Level,Family
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform