Re: Rank records in a query - crashes Access?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



I just tried removing the semicolon from the subquery, but it didn't
make any difference.

rank_qry0100 just sorts the data into the appropriate order so I can
visually see what the ranking should be - originally, the both the
main query and the sub query were based on that, but I had changed the
subquery to use the source table when I was trying to figure out why
it was crashing.

The previous method I was using to do this, which involved writing
everything to temporary tables and looping through the tables to
update the rank, required the data to be in the proper order. Looking
at this method again, I realized that the data doesn't need to be
ordered properly for this to work, so there's no point in using
rank_qry0100. I changed that so that it reads from the main table, and
that seemed to solve the problem. I have no idea why, but it seemed to
work. This is my working SQL:

SELECT A.ORIGIN_ID, A.DEST_ID, A.ROUTE_RATE, A.CAT_NAME, ((SELECT COUNT
(B.ORIGIN_ID) FROM tbl1000_CompareRates AS B WHERE B.ORIGIN_ID =
A.ORIGIN_ID AND B.DEST_ID = A.DEST_ID AND B.ROUTE_RATE < A.ROUTE_RATE)
+ 1) AS RANK
FROM tbl1000_CompareRates AS A ORDER BY A.ORIGIN_ID, A.DEST_ID,
A.ROUTE_RATE;



On Nov 17, 2:44 pm, "Michel Walsh"
<vanderghast@VirusAreFunnierThanSpam> wrote:
Remove the semi colon ending the sub-query.

Why the sub-query uses tbl1000_CompareRates  while the main query uses
rank_qry0100 ?

.



Relevant Pages

  • RE: Top values in aggregate queries
    ... > You should be able to do this by using a subquery to ... > your main query should calculate the group rank that you ... > the current records profit OR all with the same profit ...
    (microsoft.public.access.queries)
  • Top values in aggregate queries
    ... You should be able to do this by using a subquery to ... your main query should calculate the group rank that you ... Note that if you enter the criteria < 4 for this field, ...
    (microsoft.public.access.queries)
  • Top n Percent in subquery and EXISTS reserved keyword error
    ... I have achieved the query I want by adding a rank coulmn in Excel, ... Without having added the sum rank and gage rank fields, ... I have attempted the following subquery, with the dreaded error 3306 (EXISTS ...
    (microsoft.public.access.queries)
  • RE: Top values in aggregate queries
    ... subquery) in the beginning because of the syntax required ... I used VT as the alias for the second ... >> calculate the group rank of each record, ... >> results from each group in an aggregate query (not ...
    (microsoft.public.access.queries)
  • Re: Jet SQL and Virtual tables/subqueries qiestions
    ... subquery, but it's curious... ... repeated trips through the Query Editor's "graphical" side did ... The Jet Expression Evaluator (what functions & stuff are actually ... within brackets within the query. ...
    (microsoft.public.access.queries)