Reputation: 795
There is three field in my data base id(primary key),name, salary I want fetch top 3 salary from the database.
Upvotes: 1
Views: 4382
Reputation: 156
Use LIMIT to get top 3 after ordering, as such:
SELECT *
FROM myTable
ORDER BY salary DESC
LIMIT 3;
Upvotes: 1
Reputation: 499402
SQL has an ORDER BY clause that allows you do order the result set by any column/columns, ascending and descending.
For your particular question:
SELECT Id, Name
FROM myTable
ORDER BY Id DESC;
See this SO question (SQLite - sorting a table).
Upvotes: 1
Reputation: 48597
SELECT [column(s)]
FROM [table]
ORDER BY [column(s)] [ASC, DESC];
For more information check here: http://www.sqlite.org/lang_select.html
Upvotes: 1