select id, JHBH, jhmc, sbdw, sbr, sbsj, state
from (select z.id, JHBH, jhmc, sbdw, sbr, sbsj, state,llrq
from mis_wz_ckd_pb z, mis_wz_ckd_xb c
where z.id = c.pbid
and c.llrq > to_date('2012-11-4', 'yyyy-mm-dd')
and c.llrq < to_date('2012-12-6', 'yyyy-mm-dd')
and c.stostore like '%'
and z.sbr like '%%'
and replace(jhbh, '-', '') like '%%'
and z.state = '2'
order by llrq)
group by id, JHBH, jhmc, sbdw, sbr, sbsj, state
括号里已经按照llrq排序了,为什么group by之后顺序又乱了呢?该如何书写?
没加GROUP BY:
加了GROUP BY:
from (select z.id, JHBH, jhmc, sbdw, sbr, sbsj, state,llrq
from mis_wz_ckd_pb z, mis_wz_ckd_xb c
where z.id = c.pbid
and c.llrq > to_date('2012-11-4', 'yyyy-mm-dd')
and c.llrq < to_date('2012-12-6', 'yyyy-mm-dd')
and c.stostore like '%'
and z.sbr like '%%'
and replace(jhbh, '-', '') like '%%'
and z.state = '2'
order by llrq)
group by id, JHBH, jhmc, sbdw, sbr, sbsj, state
括号里已经按照llrq排序了,为什么group by之后顺序又乱了呢?该如何书写?
没加GROUP BY:
加了GROUP BY:
解决方案 »
- 关于机器名和IP变更引发oracledbconsole服务无法启动,很奇怪,如何解决?急!
- oracle9i数据库装好后(linux系统),如何再新建一个实例
- 为什么相同的数据不同的create table as select 的效率差异如此之大?
- Oracle 10g 客户端连接的问题。
- 新手的oracle问题,
- select * from table where filds='a' 怎样判断 这条语句有记录??
- 关于索引的问题
- 初学者问题:在ORACLE的LOOP当中有没有类似于DELPHI当中的continue和break的操作
- 如何生成类似余dll语句???请教
- 问题大条了,数据库联机redo日志坏了,怎么搞?在线等待中.....
- 请大师帮忙看看怎么能出来我想要的结果
- 存储过程调用不成功,求解决
Oracle用hash group代替了sort group,边读边扫,没有顺序
里面的order by llrq就多余可以去掉
from (select z.id, JHBH, jhmc, sbdw, sbr, sbsj, state,llrq
from mis_wz_ckd_pb z, mis_wz_ckd_xb c
where z.id = c.pbid
and c.llrq > to_date('2012-11-4', 'yyyy-mm-dd')
and c.llrq < to_date('2012-12-6', 'yyyy-mm-dd')
and c.stostore like '%'
and z.sbr like '%%'
and replace(jhbh, '-', '') like '%%'
and z.state = '2'
order by llrq)
group by llrq,id, JHBH, jhmc, sbdw, sbr, sbsj, state
这回试一下