Cómo obtener Top 5 registros en SQLite?


He intentado esto que no funcionó.

select top 5 * from [Table_Name]
 252
Author: Antonio Bakula, 2010-04-28

7 answers

SELECT * FROM Table_Name LIMIT 5;
 478
Author: Nix,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-04-17 17:59:20

Una declaración equivalente sería

select * from [TableName] limit 5

Http://www.w3schools.com/sql/sql_top.asp

 39
Author: Chris J,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2010-04-28 12:20:34

Los corchetes superiores y cuadrados son específicos de Transact-SQL. En ANSI SQL se usa LIMIT y backsticks (').

select * from `Table_Name` LIMIT 5;
 28
Author: newtover,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2010-04-28 11:38:18
select * from [Table_Name] limit 5
 22
Author: YOU,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2010-04-28 11:35:10
select price from mobile_sales_details order by price desc limit 5

Nota: tengo mobile_sales_details tabla

Sintaxis

select column_name from table_name order by column_name desc limit size.  

Si necesita el precio más bajo, simplemente elimine la palabra clave desc del pedido por

 19
Author: Bharathiraja,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-09-22 12:38:29
select * from [TABLE_NAME] limit 5
 4
Author: Nacho,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-09-04 20:37:36
Select TableName.* from  TableName DESC LIMIT 5
 4
Author: SGDemo,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-04-06 08:31:46