mysql 语句转换

来源:百度知道 编辑:UC知道 时间:2024/05/15 20:49:16
select * from (SELECT Distinct engine as 搜索引擎,(select sum(keywordcount) from statkeyword where engine=VR.engine and date_sub(curdate(),interval datediff('2007','2008') day) <=date(vdate) ) as 数目 FROM statkeyword as VR) as aaa order by 数目 desc limit 0,20

谁能把这条子查询语句转换成join on格式的,因为服务器的mysql版本是4.0的不支持子查询!

好像他只要通过一个简单的GROUP BY,就能实现:

SELECT
engine as 搜索引擎,
sum(keywordcount) as 数目
FROM statkeyword
WHERE
date_sub(curdate(),interval datediff('2007','2008') day) <=date(vdate)
GROUP BY
搜索引擎
ORDER BY
数目 DESC
LIMIT 0,20