优化一条sql语句(在线等,谢谢了)
rs.open "select baojiafang,rq,jia,area,shangpin from quote1 where rq in (select distinct top 10 rq from quote1 order by rq desc) and area=( '0 ') and shangpin=( '甲醇 ') group by baojiafang,rq,jia,area,shangpin ",conn,1,3
这条语句执行起来特别慢,我用的是Access数据库,数据库设计的不太好,几万条记录用时7,8秒,那位大哥能帮我优化一下啊,我sql语句很差,谢了
------解决方案--------------------select a.baojiafang,a.rq,a.jia,a.area,a.shangpin
from quote1 a inner join (select distinct top 10 rq from quote1 order by rq desc) b
on a.rq = b.rq
where and a.area=( '0 ') and a.shangpin=( '甲醇 ')
用inner join 代替in,去掉 group by