12/21/2023 0 Comments Sqlite order by clauseSqlite> SELECT * FROM CRICKETERS ORDER BY AGE, FIRST_NAME īy default, the ORDER BY clause sorts the records of a table in ascending order you can arrange the results in descending order using DESC as − Following SELECT statements sorts the records of the CRICKETERS table based on the columns AGE and FIRST_NAME. You can use more than one column to sort the records of a table. Sqlite> SELECT * FROM CRICKETERS ORDER BY AGE įirst_Name Last_Name Age Place_Of_B Country Sqlite> insert into CRICKETERS values('Rohit', 'Sharma', 32, 'Nagpur', 'India') įollowing SELECT statement retrieves the rows of the CRICKETERS table in the ascending order of their age − Sqlite> insert into CRICKETERS values('Virat', 'Kohli', 30, 'Delhi', 'India') Sqlite> insert into CRICKETERS values('Kumara', 'Sangakkara', 41, 'Matale', 'Srilanka') Sqlite> insert into CRICKETERS values('Jonathan', 'Trott', 38, 'CapeTown', 'SouthAfrica') Sqlite> insert into CRICKETERS values('Shikhar', 'Dhawan', 33, 'Delhi', 'India') Īssume we have created a table with name CRICKETERS using the following query −Īnd if we have inserted 5 records in to it using INSERT statements as − Syntaxįollowing is the syntax of the ORDER BY clause in SQLite. By default, this clause sorts results in ascending order, if you need to arrange them in descending order you need to use “DESC” explicitly. You can sort the results in desired order (ascending or descending) using the Order By clause. While fetching data using SELECT query, you will get the records in the same order in which you have inserted them. Python SQLite - Establishing Connection.Python PostgreSQL - Database Connection.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |