日期:2014-05-17  浏览次数:20488 次

【求助】数据查询求优化!
SQL code

select left(a.ssdq,6)ssdq,count(*)nan from page_czrkgl a,page_czrkgl_jtcy b where a.s1=b.gridconto_page_czrkgl 
and xb='XB1' and b.s3=1 and a.s3=1 and left(a.ssdq,6) is not null group by left(a.ssdq,6)


请问这句sql语句怎么优化能提高效率

------解决方案--------------------
除了AND LEFT(a.ssdq, 6) IS NOT NULL
可以修改为
AND a.ssdq IS NOT NULL
其它的没有什么可以修改的地方了
------解决方案--------------------
SQL code

select 
    left(a.ssdq,6)ssdq,count(*)nan 
from page_czrkgl a,page_czrkgl_jtcy b 
where a.s1=b.gridconto_page_czrkgl 
      and xb='XB1' and b.s3=1 and a.s3=1 
      and left(a.ssdq,6) is not null 
group by left(a.ssdq,6)