SQL string to return top row

  • Thread starter Thread starter Quartz
  • Start date Start date
Q

Quartz

Hello, please help if possible.

Does anyone know what the SQL string would look like to
return ALL columns for a specific number of rows (or just
the top row) of an Access DB (along with the headers)?

I've tried things like:

SELECT * FROM
WHERE ROWNUM = 1;

but Access apparently doesn't use "ROWNUM".

Your example string would be most helpful. TIA.
 
Hi Quartz,

You can use the TOP n expression to do that. Basically, the database will
return the top n row(s) that meet the criteria. For example, if you wanted
the top 5 records from a table named tblEmployees where the employee's last
name starts with "S", you would do this:

SELECT TOP 5 *
FROM tblEmployees
WHERE LastName LIKE 'S*'
ORDER BY LastName ASC

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]
 
Back
Top