Top 10 rows

L

Luke Bellamy

Hi - what is the SQL syntax Access to return the top 'x' rows
from a query?

Thanks
 
A

Allen Browne

Hi Luke.

The SQL is:
SELECT TOP 15 ...

From the interface, with your query open in design view, open the Properties
box (View menu), and set the Top Values property. If you don't see that
property, make sure you are looking at the properties of the query, not
those of a column.

Also, Access can return extra rows if there are tied values. To prevent
that, add the primary key field to the end of the ORDER BY clause: it gives
Access a way to decide which record to return.
 
L

Luke Bellamy

Great thanks Allen.. didn't seem to work using the order by query
I was using so I added the PK as you mentioned below as a secondary
order param and it worked perfectly.

Thanks
---------------
Luke Bellamy
Newcastle, Australia

Allen Browne said:
Hi Luke.

The SQL is:
SELECT TOP 15 ...

From the interface, with your query open in design view, open the Properties
box (View menu), and set the Top Values property. If you don't see that
property, make sure you are looking at the properties of the query, not
those of a column.

Also, Access can return extra rows if there are tied values. To prevent
that, add the primary key field to the end of the ORDER BY clause: it gives
Access a way to decide which record to return.
 
Top