多表 JOIN 查询统计要记得去重

多表 JOIN 查询统计要记得去重

SELECT p.id projectId,
          ccr.commit_time changeDate,
          sum(ccr.line_count) changeLine,
          now() gmtCreate,
          now() gmtModified
        FROM aone_statistics_code_commit_record ccr
        JOIN (SELECT branch_url, aone_project_id from change_request_branch where aone_project_id is not null  GROUP BY branch_url) crb on ccr.branch_url = crb.branch_url
        JOIN project p on crb.aone_project_id = p.aone_project_id where p.id = 550
        and (ccr.commit_type!= 'merge' or ccr.commit_type is null)
        and ccr.line_count < 3000
        and ccr.author not in ('apsara-scm','scm.cloud','admin.for.aone','myscm','admin.for.aliwing','admin.for.perth','shop_admin','svnadmin','admin.for.linke','search_sp_admin','van.yzt','aecp-code-manager')
GROUP BY date(changeDate);
    原文作者:一个会写诗的程序员
    原文地址: https://www.jianshu.com/p/2771669de96c
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞