pgsql SQL复杂查询示例
WITH tmp AS(
SELECT sum(sessioncount) as visitCount, appid from t_stat_visit where stattype = '1' GROUP BY appid
)
SELECT
t1.*, t2.visitCount
FROM
t_e_oauth_application t1 LEFT JOIN tmp t2 on t1.appid = t2.appid
WHERE
EXISTS (
SELECT
ID
FROM
t_e_app_version
WHERE
t1. ID = t_e_app_version.appid
AND t_e_app_version.status = '6'
)
AND t1.createorid = #{creatorId}
ORDER BY lastmodifytime DESC
编程PDF电子书免费下载: http://www.shitanlife.com/code 每天学习一点点