sqlite数据库

xiaoxiao2021-02-27  121

1.数据库排序问题 将字段依次写在order by 后面即可 , 中间用逗号隔开。

view plaincopy to clipboardprint? select * from 表 order by time , name select * from 表 order by time asc , name asc select * from 表 order by time desc , name desc select * from 表 order by time asc , name desc select * from 表 order by time desc , name asc (注: asc 表示升序 , desc表示降序 , 未明确写明排序方式时默认是升序)

与之类似的语法是 group by , 按多个字段分组时 , 也是依次将多个字段写在group by 的后面 , 并用逗号隔开 , 范例如下:

view plaincopy to clipboardprint? select time , name , sum(*) from 表 group by time , name

2.用MAX 函数返回一列中的最大值。NULL 值不包括在计算中。 SELECT MAX(column_name) FROM table_name

转载请注明原文地址: https://www.6miu.com/read-14132.html

最新回复(0)