G
Guest
I am using the following SQL in Access to run a query. I would like to limit
the number of records returned in the Horse column to the lastest 25
(specified by DateOfRace). So I'm NOT limiting the overall query to 25
records, but a subset groups of records in each Horse column.
Any ideas how I would accomplish this. I tried the TOP command but that
limits the overall query to 25 records.
SELECT Profiler.Track, Profiler.RaceNumber, Profiler.PgmNum, Profiler.Horse,
Profiler.MLOdds, Profiler.Trainer, Profiler.Jockey, RaceChart.DateOfRace,
RaceChart.Track, RaceChart.RaceNum, RaceChart.RaceClassification,
RaceChart.Dist, RaceChart.Horse, RaceChart.FinishPos, RaceChart.[Win$],
Count("Rank:") AS Expr1
FROM Profiler LEFT JOIN RaceChart ON Profiler.Trainer = RaceChart.Trainer
GROUP BY Profiler.Track, Profiler.RaceNumber, Profiler.PgmNum,
Profiler.Horse, Profiler.MLOdds, Profiler.Trainer, Profiler.Jockey,
RaceChart.DateOfRace, RaceChart.Track, RaceChart.RaceNum,
RaceChart.RaceClassification, RaceChart.Dist, RaceChart.Horse,
RaceChart.FinishPos, RaceChart.[Win$]
HAVING (((Count("Rank:"))>=20))
ORDER BY Count("Rank:");
the number of records returned in the Horse column to the lastest 25
(specified by DateOfRace). So I'm NOT limiting the overall query to 25
records, but a subset groups of records in each Horse column.
Any ideas how I would accomplish this. I tried the TOP command but that
limits the overall query to 25 records.
SELECT Profiler.Track, Profiler.RaceNumber, Profiler.PgmNum, Profiler.Horse,
Profiler.MLOdds, Profiler.Trainer, Profiler.Jockey, RaceChart.DateOfRace,
RaceChart.Track, RaceChart.RaceNum, RaceChart.RaceClassification,
RaceChart.Dist, RaceChart.Horse, RaceChart.FinishPos, RaceChart.[Win$],
Count("Rank:") AS Expr1
FROM Profiler LEFT JOIN RaceChart ON Profiler.Trainer = RaceChart.Trainer
GROUP BY Profiler.Track, Profiler.RaceNumber, Profiler.PgmNum,
Profiler.Horse, Profiler.MLOdds, Profiler.Trainer, Profiler.Jockey,
RaceChart.DateOfRace, RaceChart.Track, RaceChart.RaceNum,
RaceChart.RaceClassification, RaceChart.Dist, RaceChart.Horse,
RaceChart.FinishPos, RaceChart.[Win$]
HAVING (((Count("Rank:"))>=20))
ORDER BY Count("Rank:");