Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Select Max(field1) + its corresponding fields?
Message
 
 
To
22/10/2001 11:08:07
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00571652
Message ID:
00571660
Views:
22
>Field1, Field2
>10, 4
>15, 3
>7, 9
>Select Max(field1),field2 from table1
>does not work the way I need it to be. I need the max. value in Field1 (=15), and it's corresponding field2 (=3). The above select statement will give me the correct field1, but not returning its corresponding field2. I think it returns the first record in field2 instead.
>Is there a way to achieve what I need?
>Thank you all!!

If you have an index on Field2, the following code will give you all records, which have max Field2:
select field1, field2 from Table1 where field2 in (select max(field2) from table1)
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform