Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2006

    Unanswered: How Do I display # of Records based on a Count

    I am trying to figure out as to how I can display a # of records based on a count?

    To start at the beginning: I am creating a program that will print 15 apps per agent per day. I have already resolved the issue in printing these apps but now I am trying to figure out how to add new records to a table to add up to the quota of 15.

    Here is an example:
    Sample_App Table-containing customer info for the applications including the agent's info.

    I had ran a query from that table and produce a listing giving me a count of each app per agent:

    Agent Name # of Apps
    John Smith 131
    Mary Smith 90
    Bob Jones 8

    Now here is the problem:

    Bob Jones does not have enough apps to reach the quota of 15, so I wish to get the needed records from a second table.

    I had created several queries and they are:

    1. Select Query: to choose the agent with less than 15 apps.
    2. Sub Query: using the query (from #1) and calculate the difference from "15" and have a new field (AResult) showing the result.
    3. Select Query: a new query for the second table in which the TOTAL function is turned on and having the field (ID) counted.

    I had tried to use the result from Query #2 in Query #3, to display the required # of records in its selections so that it can be used in another query and append to the first table, but I keep getting aggregate errors.

    Please advise as to what will be the best solution.

    Thank you.

  2. #2
    Join Date
    Mar 2009
    Provided Answers: 14
    Try using a SELECT TOP n query.
    Have a nice day!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts