2 Field Max
Posted 15 January 2003 - 01:11 AM
It looks something like this:
I need to create a query that selects the latest yrnumber COMBO. In this case, it would be 2003, 1.
Here is what I have tried:
SELECT MAX(yr), MAX(number) FROM issue
returned 2003, 2
SELECT MAX(yr), MAX(number) FROM issue WHERE yr=MAX(yr)
SELECT yr, number FROM issue WHERE yr=MAX(yr) AND number=MAX(number)
Both returned error \"Invalid use of group function\"
Any other ideas? I know mysql does not support sub-queries, so do I have to use two?
Sorry to bug you on a seemingly trivial issue, but I TRY to always learn how to do things the in the best and most efficient manner.
Posted 15 January 2003 - 01:32 AM
SELECT yr, number FROM issue WHERE (MAX(yr) AND MAX(number))
I always like to put () around any AND/OR statements just to be safe. I think it will work without it though
Posted 15 January 2003 - 02:37 AM
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users