A
Appelq
I have a table tblTractorRevenue.
TractorID, Location, Revenue
1234 , 01 , $100
1235 , 01 , $250
.....
5412 , 99 , $125
Each Location has some number of tractors (ex: Location 01 has 30 tractors,
02 has 10, etc.)
I need to list a report, sorted by Location, showing the top 10% revenue
tractors and the Bottom 10 % revenue tractors for Each location)
First, I did a MakeTable query to get the 10% number of tractors for each
location:
Location, Cnt
01 , 30
02 , 10
....
99 , 15
I thought I would write a bit of VB to loop through the table (sorted By
Location, By Revenue DESC) and flag the Top 10% tractors (first 3 for
location 01) and flag the bottom 10% for that location. I have a field in
tblTractorrevenue - TopBottom that can be either "T" or "B" or Null.
Once all of the records are flagged I could then run a query to select *
FROM tblTractorRevenue WHERE TopBottom Not Null and do my thing.
I'm having trouble designing the nested looping structure to do this in VB.
OR is there a better approach to get to my objective?
thanks in advance,
Chuck
TractorID, Location, Revenue
1234 , 01 , $100
1235 , 01 , $250
.....
5412 , 99 , $125
Each Location has some number of tractors (ex: Location 01 has 30 tractors,
02 has 10, etc.)
I need to list a report, sorted by Location, showing the top 10% revenue
tractors and the Bottom 10 % revenue tractors for Each location)
First, I did a MakeTable query to get the 10% number of tractors for each
location:
Location, Cnt
01 , 30
02 , 10
....
99 , 15
I thought I would write a bit of VB to loop through the table (sorted By
Location, By Revenue DESC) and flag the Top 10% tractors (first 3 for
location 01) and flag the bottom 10% for that location. I have a field in
tblTractorrevenue - TopBottom that can be either "T" or "B" or Null.
Once all of the records are flagged I could then run a query to select *
FROM tblTractorRevenue WHERE TopBottom Not Null and do my thing.
I'm having trouble designing the nested looping structure to do this in VB.
OR is there a better approach to get to my objective?
thanks in advance,
Chuck