Cutoff at "Top300Customers"

  • Thread starter Thread starter Rick Brown
  • Start date Start date
R

Rick Brown

I have queries joining customer and sales tables and then a report print
mailing labels for them. I have the query listing in descending Total Sales
order for a date range. What I want to do is cut the list off at the top
(first) 300 customers. How can I do that?

Thanks,

Rick Brown
 
Look at the TOP predicate in SQL. Something like:

SELECT TOP 300 Field1, Field2 FROM Table1 WHERE...

It is important, however to Sort your results properly.
 
That works. However I'd like to put it in the query grid so I can make the
actual # of records to return a parameter. I'm sorry I wasn't more specific.
Is there an equivalent way to do it that way?

Thanks,

Rick Brown
 
Well, you can't have a parameter for the TOP value. It just isn't
available. What I have done is to programmatically recreate and save the
query with the values that you want (you can populate them from a form as
well) and then execute the query. As far as I know, that's the only way to
make the TOP value user selectable.

On my website is a small sample database called "CreateQueries2.mdb" which
illustrates creating queries programmatically. Although it doesn't
specifically address the TOP predicate, the process would be similar.
 
Back
Top