Return Top 10 Record

R

rahmad

Hi All,
Below is the SQL Statement of my query.I sort the Fields
HEIGHT descently,But I want the query return the 10 Highest
only.
Is there some body would like to help,how to do that easyly.

SELECT HEIGHT.Name, Sum(HEIGHT.Height) AS SumOfHeight
FROM HEIGHT
GROUP BY HEIGHT.Name
ORDER BY Sum(HEIGHT.Height) DESC;

Thank's
 
F

fredg

Hi All,
Below is the SQL Statement of my query.I sort the Fields
HEIGHT descently,But I want the query return the 10 Highest
only.
Is there some body would like to help,how to do that easyly.

SELECT HEIGHT.Name, Sum(HEIGHT.Height) AS SumOfHeight
FROM HEIGHT
GROUP BY HEIGHT.Name
ORDER BY Sum(HEIGHT.Height) DESC;

Thank's

Select Top 10 HEIGHT.Name, etc........

Note: Name is a reserved Access/VBA/Jet word and should not be used as
a field name. Also, you should not use a property name (Height) as
field name as well... and naming a field and table the same can only
cause confusion. Try adding a qualifier, i.e. txtName, txtHeight,
tblHeight, etc. to differentiate objects.

For additional reserved words, see the Microsoft KnowledgeBase article
for your version of Access:

109312 'Reserved Words in Microsoft Access' for Access 97
209187 'ACC2000: Reserved Words in Microsoft Access'
286335 'ACC2002: Reserved Words in Microsoft Access'
321266 'ACC2002: Microsoft Jet 4.0 Reserved Words'

For an even more complete list of reserved words, see:
http://www.allenbrowne.com/AppIssueBadWord.html
 
R

rahmad

OK fredg,
I got it but my problem is not with the 'name' or the 'fields name'.
Do you have idea to solve my problem?.
 
A

Allen Browne

In query design view, open the properties box.

Set the query's Top Values property to: 10

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

rahmad said:
OK fredg,
I got it but my problem is not with the 'name' or the 'fields name'.
Do you have idea to solve my problem?.
 
F

fredg

OK fredg,
I got it but my problem is not with the 'name' or the 'fields name'.
Do you have idea to solve my problem?.

I don't understand!
Didn't I just give you the answer?
Change
Select HEIGHT.Name, etc...
to
Select Top 10 HEIGHT.Name, etc....

In Access help files click on
Index + Top + Show only the high or low values in a query.

And if you think that your use of Name and Height as field names is
not causing you a problem, just wait. It will.
 
C

cho

fredg said:
I don't understand!
Didn't I just give you the answer?
Change
Select HEIGHT.Name, etc...
to
Select Top 10 HEIGHT.Name, etc....

In Access help files click on
Index + Top + Show only the high or low values in a query.

And if you think that your use of Name and Height as field names is
not causing you a problem, just wait. It will.
 
R

rahmad

Thank's All,
It works nice now.
For fredg,actually my field's name are not like
'name' and 'height',I create that database just
to ease my explanation with a simple sample.
Thank's for your advise and Allen too.
Have anice day


 

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