如何在sqlite中获取有序查询?

时间:2014-06-02 07:49:03

标签: sqlite

我将一些数据插入测试表。

C:\>  sqlite3 e:\\test.db
sqlite> create table test(code TEXT,content  numeric);
sqlite> insert into test(code,content)values('x',3);
sqlite> insert into test(code,content)values('x',1.5);
sqlite> insert into test(code,content)values('x',1);
sqlite> insert into test(code,content)values('y',9);
sqlite> insert into test(code,content)values('y',3);
sqlite> insert into test(code,content)values('y',2);
sqlite> insert into test(code,content)values('y',12.3);
sqlite> insert into test(code,content)values('y',11.5);

如何获得如下的有序输出?
select * from test group by code order by content;无法得到它。 select * from test order by content;既不。

x|1
x|1.5
x|3
y|2
y|3
y|9
y|11.5
y|12.3

1 个答案:

答案 0 :(得分:0)

您可以按多个条件排序:

SELECT * FROM test ORDER BY code, content;