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

 

 

 

 

 
posted @ 2018-05-16 09:09  漫步CODE人生  阅读(1247)  评论(0编辑  收藏  举报