essaytee
Need a good one-liner.
- Local time
- Today, 17:15
- Joined
- Oct 20, 2008
- Messages
- 538
I'm returning to some Access data manipulation and I've come across a situation I thought was possible, but can't figure it out. I have adopted a work-around (explained at the end), but I thought there is a less-convoluted way.
I have a table that records running times of runners for each week of running. I scrape the data from Strava. The fields are, Week Ending date, Runners Name, Max Distance, Longest Run, Elevation, Number of runs and pace. There is also a primary key. For each week there are about 60 - 70 records.
I want to produce reports each week against all the categories, in descending order (ascending order for pace). So for Max Distance, the first record will be the max distance, obviously. I want to also include the position number, against all the records. The position number is not a field in the table. Is there a way in SQL to dynamically create the position number and incremented by 1 for each record? The runner that is in position 1 for the max distance for the week, may not be in position 1 for the longest run for week, and likewise for the other categories.
My work-around is as follows. Use VBA. Queries already created for the various categories, filtered to the desired week ending date and sorted accordingly. Create a temporary table, that is the same as the base table but with an additional field, Position. That temporary table is populated with data from the query (via Recordset.AddNew process) and the Position field starts at 1 and incremented by 1 for each next record. The temporary table is then the record source of a report.
Is there a simpler way or another way?
I have a table that records running times of runners for each week of running. I scrape the data from Strava. The fields are, Week Ending date, Runners Name, Max Distance, Longest Run, Elevation, Number of runs and pace. There is also a primary key. For each week there are about 60 - 70 records.
I want to produce reports each week against all the categories, in descending order (ascending order for pace). So for Max Distance, the first record will be the max distance, obviously. I want to also include the position number, against all the records. The position number is not a field in the table. Is there a way in SQL to dynamically create the position number and incremented by 1 for each record? The runner that is in position 1 for the max distance for the week, may not be in position 1 for the longest run for week, and likewise for the other categories.
My work-around is as follows. Use VBA. Queries already created for the various categories, filtered to the desired week ending date and sorted accordingly. Create a temporary table, that is the same as the base table but with an additional field, Position. That temporary table is populated with data from the query (via Recordset.AddNew process) and the Position field starts at 1 and incremented by 1 for each next record. The temporary table is then the record source of a report.
Is there a simpler way or another way?