请高手指点SQL语句
select count(a.数据) as aa,
count(distinct a.数据) as bb,
(count(a.数据) / count(distinct a.数据)) as cnum
from push_send a where
a.datetime> =to_date( '2006-10-1 ', 'yyyy-mm-dd ') and
a.datetime <to_date( '2007-1-1 ', 'yyyy-mm-dd ')
语句意思是查寻10月到12月数据总量,不重复数据总量,再用总量除不重复的总量
这样方法速度太慢 请高手给与修改 谢谢
------解决方案--------------------把测试计划贴出来
------解决方案--------------------看你的执行计划,
------解决方案--------------------select cc.aa,cc.bb,cc.aa/cc.bb from
(select count(a.数据) as aa,count(distinct a.数据) as bb
from push_send a where
a.datetime> =to_date( '2006-10-1 ', 'yyyy-mm-dd ') and
a.datetime <to_date( '2007-1-1 ', 'yyyy-mm-dd ')) cc;