sqlite数据库

来源:互联网 发布:网络推广考核标准 编辑:程序博客网 时间:2024/06/10 03:02

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

0 0