如题
select to_char(ubac.usetime,'yyyy-mm-dd'
from wap_t_comm_manufacturer cm
join wap_t_re_manufacturer_channel rmc on rmc.E_id=cm.ID join wap_t_comm_channel cc on cc.id=rmc.catagory_id
join wap_t_re_business_channel rbc on rbc.soid=cc.id join wap_t_comm_business cb on cb.id=rbc.opid
join wap_t_comm_sp cs on cs.spno=cb.sp_id join wap_t_user_business_access ubac on ubac.opno=cb.opno
where ubac.usetime between to_date('2009-05-01 00','yyyy-mm-dd hh24:mi:ss') and to_date('2009-05-31 00','yyyy-mm-dd hh24:mi:ss')
group by to_char(ubac.usetime,'yyyy-mm-dd')为什么得到的结果有四月的数据?
select to_char(ubac.usetime,'yyyy-mm-dd'
from wap_t_comm_manufacturer cm
join wap_t_re_manufacturer_channel rmc on rmc.E_id=cm.ID join wap_t_comm_channel cc on cc.id=rmc.catagory_id
join wap_t_re_business_channel rbc on rbc.soid=cc.id join wap_t_comm_business cb on cb.id=rbc.opid
join wap_t_comm_sp cs on cs.spno=cb.sp_id join wap_t_user_business_access ubac on ubac.opno=cb.opno
where ubac.usetime between to_date('2009-05-01 00','yyyy-mm-dd hh24:mi:ss') and to_date('2009-05-31 00','yyyy-mm-dd hh24:mi:ss')
group by to_char(ubac.usetime,'yyyy-mm-dd')为什么得到的结果有四月的数据?
发现一个很奇怪的问题如果查询语句如下,即时间限定在where的最前面,就会出现四月分的数据
select to_char(ubac.usetime,'yyyy-mm-dd'
from wap_t_comm_manufacturer cm
join wap_t_re_manufacturer_channel rmc on rmc.E_id=cm.ID join wap_t_comm_channel cc on cc.id=rmc.catagory_id
join wap_t_re_business_channel rbc on rbc.soid=cc.id join wap_t_comm_business cb on cb.id=rbc.opid
join wap_t_comm_sp cs on cs.spno=cb.sp_id join wap_t_user_business_access ubac on ubac.opno=cb.opno
where ubac.usetime between to_date('2009-05-01 00','yyyy-mm-dd hh24:mi:ss') and to_date('2009-05-31 00','yyyy-mm-dd hh24:mi:ss')
and cb.id='123' or cb.opno='123'
group by to_char(ubac.usetime,'yyyy-mm-dd') 但是如果时间限定在where的最后面,就不会出现四月份的数据,难道where中条件的顺序也会影响结果吗?
select to_char(ubac.usetime,'yyyy-mm-dd'
from wap_t_comm_manufacturer cm
join wap_t_re_manufacturer_channel rmc on rmc.E_id=cm.ID join wap_t_comm_channel cc on cc.id=rmc.catagory_id
join wap_t_re_business_channel rbc on rbc.soid=cc.id join wap_t_comm_business cb on cb.id=rbc.opid
join wap_t_comm_sp cs on cs.spno=cb.sp_id join wap_t_user_business_access ubac on ubac.opno=cb.opno
where cb.id='123' or cb.opno='123' and
ubac.usetime between to_date('2009-05-01 00','yyyy-mm-dd hh24:mi:ss') and to_date('2009-05-31 00','yyyy-mm-dd hh24:mi:ss')
group by to_char(ubac.usetime,'yyyy-mm-dd')
where ubac.usetime between to_date('2009-05-01 00','yyyy-mm-dd hh24:mi:ss') and to_date('2009-05-31 00','yyyy-mm-dd hh24:mi:ss')
and (cb.id='123' or cb.opno='123')
应该可以的!
明显有括号和无括号的意思不一样的!