Hello,
Does anyone know how to select the top row of each group, and display all the records in the table for that row, without writing a subquery?
For example, my table has a date field and a location field, plus several other records. I want to run a query that gets all of the fields for the most recent date, per location.
This only gets the location and the date, but no extra fields:
select max(mc_date), mc_location
from csq_mc
group by mc_location
and if I add the extra fields to the SELECT statement, then ALL of the records are returned.
Can I get just the top date by location, plus the location, plus the other records?
Thanks,
Peter
Does anyone know how to select the top row of each group, and display all the records in the table for that row, without writing a subquery?
For example, my table has a date field and a location field, plus several other records. I want to run a query that gets all of the fields for the most recent date, per location.
This only gets the location and the date, but no extra fields:
select max(mc_date), mc_location
from csq_mc
group by mc_location
and if I add the extra fields to the SELECT statement, then ALL of the records are returned.
Can I get just the top date by location, plus the location, plus the other records?
Thanks,
Peter