Rows

  • Thread starter turks67 via AccessMonster.com
  • Start date
T

turks67 via AccessMonster.com

Is there a way to show the first Five rows in a query that has Forty rows.
 
D

Dirk Goldgar

turks67 via AccessMonster.com said:
Is there a way to show the first Five rows in a query that has Forty rows.


In what context? You can size a continuouis form so that only 5 rows show,
but I think that may be too simple for what you really want. More likely,
you can write a query that returns the TOP 5 records from the original
query, ordered by some unique set of key fields. For example:

SELECT TOP 5 MyQuery.* FROM MyQuery
ORDER BY SomeField;
 
D

Douglas J. Steele

Dirk Goldgar said:
In what context? You can size a continuouis form so that only 5 rows
show, but I think that may be too simple for what you really want. More
likely, you can write a query that returns the TOP 5 records from the
original query, ordered by some unique set of key fields. For example:

SELECT TOP 5 MyQuery.* FROM MyQuery
ORDER BY SomeField;

Just be aware that should there be ties in the values for SomeField, you may
get more than 5 rows returned.
 
D

Dirk Goldgar

Douglas J. Steele said:
Just be aware that should there be ties in the values for SomeField, you
may get more than 5 rows returned.


Yup -- that's why I said, " ordered by some unique set of key fields". If
the fields ordered by are unique, then ties cannot occur. If the table or
query doesn't contain any set of fields that can be counted on to be unique,
though, you could get more than 5 rows returned. Normally a table will have
a primary key, and one can include the primary key field(s) in the ORDER BY
clause to ensure that there are no ties.
 

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