Limiting return data to a power table with a select query

This is the example. I get errors when I add the Limit 1000. Any Ideas
SELECT * FROM table Where equipment # =1 Order by Timestamp desc limit 1000

select top 1000 * …

The syntax varies among database types. For MySQL and PostgreSQL, the LIMIT clause is used at the end of the query. For MS SQLServer, the TOP clause is placed just after “SELECT”. For Oracle, you have to use a subquery and filter on rownum, if I recall correctly.

for Oracle you can add it to the where clause:

AND rownum <= 1000

Be very careful with this – the comparison is applied before the ORDER BY clause is evaluated. You might get no rows at all. See the Oracle Docs on ROWNUM.

1 Like

True, as you stated before, use a sub-query to control the order of operations with Oracle.
As a rule, I group and summarize things that are presented to the user so they don’t have to look through thousands of records; I sometimes forget that others use different ways to limit the volume of records displayed.