【发布时间】:2014-07-22 06:47:28
【问题描述】:
我在测试表中插入了一些数据。
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;neither.
x|1
x|1.5
x|3
y|2
y|3
y|9
y|11.5
y|12.3
【问题讨论】:
-
如果你想按时间顺序排列结果,比如最近的在前,或者最旧的在前,那么你需要在你的表中添加一个自动时间戳。见stackoverflow.com/questions/14461851/…
标签: sqlite