黄色电影一区二区,韩国少妇自慰A片免费看,精品人妻少妇一级毛片免费蜜桃AV按摩师 ,超碰 香蕉

SQLite Order By

sqlite order by

sqlite 的 order by 子句是用來基于一個或多個列按升序或降序順序排列數(shù)據(jù)。

 

1. 語法

order by 子句的基本語法如下:

select column-list 
from table_name 
[where condition] 
[order by column1, column2, .. columnn] [asc | desc];

您可以在 order by 子句中使用多個列。確保您使用的排序列在列清單中。

 

2. 范例

假設(shè) company 表有以下記錄:

id          name        age         address     salary
----------  ----------  ----------  ----------  ----------
1           paul        32          california  20000.0
2           allen       25          texas       15000.0
3           teddy       23          norway      20000.0
4           mark        25          rich-mond   65000.0
5           david       27          texas       85000.0
6           kim         22          south-hall  45000.0
7           james       24          houston     10000.0

下面是一個范例,它會將結(jié)果按 salary 升序排序:

sqlite> select * from company order by salary asc;

這將產(chǎn)生以下結(jié)果:

id          name        age         address     salary
----------  ----------  ----------  ----------  ----------
7           james       24          houston     10000.0
2           allen       25          texas       15000.0
1           paul        32          california  20000.0
3           teddy       23          norway      20000.0
6           kim         22          south-hall  45000.0
4           mark        25          rich-mond   65000.0
5           david       27          texas       85000.0

下面是一個范例,它會將結(jié)果按 name 和 salary 升序排序:

sqlite> select * from company order by name, salary asc;

這將產(chǎn)生以下結(jié)果:

id          name        age         address     salary
----------  ----------  ----------  ----------  ----------
2           allen       25          texas       15000.0
5           david       27          texas       85000.0
7           james       24          houston     10000.0
6           kim         22          south-hall  45000.0
4           mark        25          rich-mond   65000.0
1           paul        32          california  20000.0
3           teddy       23          norway      20000.0

下面是一個范例,它會將結(jié)果按 name 降序排序:

sqlite> select * from company order by name desc;

這將產(chǎn)生以下結(jié)果:

id          name        age         address     salary
----------  ----------  ----------  ----------  ----------
3           teddy       23          norway      20000.0
1           paul        32          california  20000.0
4           mark        25          rich-mond   65000.0
6           kim         22          south-hall  45000.0
7           james       24          houston     10000.0
5           david       27          texas       85000.0
2           allen       25          texas       15000.0

下一節(jié):sqlite group by

sqlite教程

相關(guān)文章