Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 498195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T05:51:17+00:00 2026-05-13T05:51:17+00:00

So I have a query that is a Top Nth aggregate query, and I

  • 0

So I have a query that is a Top Nth aggregate query, and I have another query built from that one that returns all the offices/locations grouped for each of the top sales. I want to make a report that counts the number of offices associated with each of these top Nth ID values that are returned in this query. I want to use a domain aggregate expression in text boxes on the report so that I do not have to spend time each month looking up those IDs to determine what needs to go into the expression.

So is there an expression I can add to the second query that will assign a number descending number to the IDs?

The first query looks like: /

ID#    ITEM             Sold  /
765    Lawnmowers        75  /
764    Weed trimmers     64  /
etc

the second query looks like: /

ID#    ITEM             Sold         Location   /
 /
765    Lawnmowers        75          New York  /
765    Lawnmowers        75          Maryland  /
765    Lawnmowers        75          Ohio     /
765    Lawnmowers        75          Virginia   /
764    Weed trimmers     64          Florida
764    Weed trimmers     64          north Carolina   /

I need:
/

ID#    ITEM             Sold         Location          IDGroup#   /

765    Lawnmowers        75          New York                 1   /
765    Lawnmowers        75          Maryland                 1   /
765    Lawnmowers        75          Ohio                     1   / 
765    Lawnmowers        75          Virginia                 1   /
764    Weed trimmers     64          Florida                  2   /
764    Weed trimmers     64          north Carolina           2   /

please help. thanks! i am pulling my hair on this one!

what i am trying to do is be able to report the number of items sold (done), how many locations sold the item (need dynamically) for a given time period.

i was trying to use an DCount expression but if I use the Product ID, it does me no good because these figures change monthly (this is all based from a Top Ten query to begin with)

i know i confuse myself with this question 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T05:51:18+00:00Added an answer on May 13, 2026 at 5:51 am

    To answer your question, yes it’s possible. You can use the Switch function. Ex:
    Switch(“LawnMower”,1,”Weed trimmers”,2) etc. Of course this requires you to put an entry for every unique value in the table and is pretty much a horrible id for anything but a throw-away query with a small number of groups.

    A more orthodox approach would be to create a lookup table with two fields: “Item” and “Group”. Make item the primary key and make “Group” a AutoNumbered field. Next you will need to create a Select Distinct query to get the unique items in the original table. Turn this query into an append query and pipe the values into your lookup table (sorting however you like). The autonum field will automatically assign sequential IDs to these records.

    Now you can just take your original query and add a join to your lookup table to pull in a group id.

    Addendum: If more than one item can be in a group, simply use the ITEM make the ID field a non-unique numeric long and then key the entries manually (it shouldn’t take too long since it will be unique entries). Either way, with this approach you should be able to maintain your groups with relative ease going forward.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a SQL query that current returns the top 50 rows from a
I have a query that pulls up questions from one table and answers from
I have a query that is dynamically built after looking up a field list
I have a query that I'm executing from a .NET application to a SQL
I have a query that I am generating the XML from in Oracle using
I have a query that returns rows in the following format: ID NAME PARENTID
I have a query that returns a datetime field and several other fields along
I have a query regarding accessibility of top level class from member inner class.
I have a query that select the top 5 of the UID that most
I have a query that originally looks like this: select c.Id, c.Name, c.CountryCode, c.CustomerNumber,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.