Questions tagged [sql-limit]

SQL clause to limit number of returned rows

The LIMIT clause is used to specify a maximum of rows to be returned in a SELECT query. The various SQL dialects use different syntax elements for that purpose. LIMIT x OFFSET y, is understood by MySQL, PostgreSQL, SQLite and some others RDBMS.
Example:

SELECT * FROM tbl LIMIT 10;

The SQL:2008 standard defines:

FETCH FIRST n ROWS ONLY

SQL Server uses TOP n, Oracle its rownum feature.
There is a comprehensive list on Wikipedia.

258 questions
-2
votes
3 answers

No MySQL records return when past a certain limit?

I have the following query which returns 250 records: SELECT DISTINCT p.* FROM Persons AS p INNER JOIN Colors AS c ON c.ColorId = p.FavoriteColorId WHERE p.Name = 'John Doe' AND c.ColorName IN ('RED','BLUE','YELLOW') …
Xaisoft
  • 42,877
  • 83
  • 270
  • 415
-3
votes
1 answer

Sql query find the car whcih is having maximim mileage

find the car whcih is having maximum mileage id,car,timestamp,mileage 101,audi,10/10/10 9:05:02,10.5 101,audi,10/10/10 9:07:02,10 101,audi,10/10/10 9:14:02,9 102,benz,10/10/10 8:24:02,8 102,benz,10/10/10 8:34:02,7 102,benz,10/10/10…
user10508414
-3
votes
1 answer

How to limit query results by a percentage of the total number of results in MySQL?

The below mysql question returns only the 10 first rows. How can I limit the them to 10% of all? SELECT page, poso, diff FROM (SELECT page, Count(*) AS poso, ( Sum(Date(timestamp) = Curdate()) -…
EnexoOnoma
  • 7,471
  • 16
  • 82
  • 166
1 2 3
17
18