Select Top ???

  • Thread starter Thread starter mcl
  • Start date Start date
M

mcl

Is it possible to somehow set the input to select top to a variable or at
least use some other method to get the same effect. If I could just use
something like select top (query.variable) etc etc that would be great but
it obviously doesn't work. I want to be able to use other queries to
generate the numeric input for the select top statement but so far that
seems to be impossible.
 
You can possibly create a rank/sequence value in your query so your
results/records are numbered from 1 to... You can then set a criteria under
this rank to be <= a specfic value.
 
Here is an example that uses the customer table from the Northwind MDB.

SELECT Val(DCount("CustomerID","Customers","CustomerID <='" & [CustomerID] &
"'")) AS TopNum, Customers.*
FROM Customers
WHERE (((Val(DCount("CustomerID","Customers","CustomerID <='" & [CustomerID]
& "'")))<=Val([Enter Top Number])))
ORDER BY Customers.CustomerID;
 
Back
Top