AdBlock Detected!
Our website is made possible by displaying ads to our visitors. Please supporting us by whitelisting our website.
SQL LIMIT |
SQL > Advanced SQL >
Limit
The LIMIT clause restricts the number of results returned from a SQL statement. It is available in MySQL, Hive, and Google BigQuery. SyntaxThe syntax for LIMIT is as follows: [SQL Statement 1]
LIMIT [N]; where [N] is the number of records to be returned. Please note that the ORDER BY clause is usually included in the SQL statement. Without the ORDER BY clause, the results we get would be dependent on what the database default is. ExampleWe use the following table for our example. Table Store_Information
To retrieve the two highest sales amounts in Table Store_Information, we key in, SELECT Store_Name, Sales, Txn_Date
FROM Store_Information ORDER BY Sales DESC LIMIT 2; Result:
The SQL Server equivalent to LIMIT is TOP.
|
Our website is made possible by displaying ads to our visitors. Please supporting us by whitelisting our website.