select * from data a where (a.surveytime between to_date('2010-11-9 08:00:00','yyyy-mm-dd hh24:mi:ss') and to_date('2010-11-10 08:00:00','yyyy-mm-dd hh24:mi:ss')) and a.stid='50' order by surveyTime
我在查询的时候按时间排序时,有时候在同一个时间点有多条数据,所以这几条数据就无法按时间顺序来排序了。
请教 如何让查询出来的数据按存入数据库的先后顺序排序呢?
2、如果同一时间出现多个数据,只能再按其它字段再排序,如:order by surveyTime,other_files 如果没有其它字段是不行的。
from data a
where (a.surveytime between
to_date('2010-11-9 08:00:00', 'yyyy-mm-dd hh24:mi:ss') and
to_date('2010-11-10 08:00:00', 'yyyy-mm-dd hh24:mi:ss'))
and a.stid = '50';
请问下, 我按ID来排序 是不是应该在ID上建立以个索引呢?(这个表没有建主键,所以ID不是主键)
如果需要 求在ID上建立索引的代码,谢谢。
请教一下order by surveyTime,other_files 像这样是不是先按surveyTime这个排序,当同一时间有多条数据时,会自动让那几条数据以other_files 这个顺序排序吗?
2、排序字段上建立索引是正确的选择。