how do I display data related to a top 10 query in access?

G

Guest

Hello, I am trying to run a query on a table that returns the top 10 of a
field. i.e
The table contains 3 columns, meal type(meat,veg,fruit,cereal). male or
female. meal contents
(pork,lamb,chicken,potatoes,carrots,bananas,apples,weetabix,cornflakes etc)

I can run the query so that it puts the top ten meal types in descending
order and show me the count and whether it was a male or female that chose
it. ie:- Meat,23,male. when i add the meal contents to the
query, It sorts it in to top ten for the contents. I don't want that to
happen. I want to be able to display on a report what each of those 23
meats were ie 10 pork,10,lamb,3,chicken. Any ideas?
 
G

Guest

Rick Brandt said:
My understanding is that the "top" in a TOP query is determined by the fields
you sort on. If you add additional fields, just don't sort on them and they
shouldn't affect the rows returned.

Hi Rick, thanks for the reply, I am only sorting the count of meal type
column. this gives me,ie meat, 23, male
fruit,13,female
etc,etc
What happens when i add the contents column(unsorted) is this
meat,5,male,pork
fruit,5,female,apples
What I want is:-
meat,23,male,pork
meat,23,male,pork x5 etc etc
listing all the 23 different meats, does this make any sense??
 
R

Rick Brandt

crimminsky said:
Hello, I am trying to run a query on a table that returns the top 10
of a field. i.e
The table contains 3 columns, meal type(meat,veg,fruit,cereal). male
or female. meal contents
(pork,lamb,chicken,potatoes,carrots,bananas,apples,weetabix,cornflakes
etc)

I can run the query so that it puts the top ten meal types in
descending order and show me the count and whether it was a male or
female that chose it. ie:- Meat,23,male. when i add
the meal contents to the query, It sorts it in to top ten for the
contents. I don't want that to happen. I want to be able to
display on a report what each of those 23 meats were ie 10
pork,10,lamb,3,chicken. Any ideas?

My understanding is that the "top" in a TOP query is determined by the fields
you sort on. If you add additional fields, just don't sort on them and they
shouldn't affect the rows returned.
 
R

Rick Brandt

crimminsky said:
Hi Rick, thanks for the reply, I am only sorting the count of meal
type column. this gives me,ie meat, 23, male
fruit,13,female
etc,etc
What happens when i add the contents column(unsorted) is this
meat,5,male,pork
fruit,5,female,apples
What I want is:-
meat,23,male,pork
meat,23,male,pork x5 etc etc
listing all the 23 different meats, does this make any sense??

Then feed an initial query that gives you the TOP that you want into a second
query that adds the additional fields.
 
G

Guest

:

Then feed an initial query that gives you the TOP that you want into a second
query that adds the additional fields.

--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com


Cheers Rick, Can you give me a quick pointer on how to do that? I have been trying differen't things for a while now and it's driving me mad

cheers in advance
 
R

Rick Brandt

crimminsky said:
:



cheers in advance

Create a TOP 10 query usign the fields that give you the rows you want (even if
it doesn't contain all the fields you want). Save that query, then build
another one and for inputs include the same tables as your first query and also
include the first query. Then you can include all fields from the first query
and add any additional fields that you want to see. You will obviously have to
add joins lines as appropriate.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top