标签:SQL
--子查询方式-- 按照费率表的数量来展示
SELECT A.ORGANNO,O.ORGANNAME,A.RATE,nvl(T.VRC,0),nvl(T.PSATF,0),nvl(T.VTF,0) FROM TB_ACCRATE A
LEFT JOIN TB_ORGAN O ON A.ORGANNO=O.ORGANNO
LEFT JOIN (SELECT R.ORGANNO, R.ORGANNAME, SUM(R.VRC) VRC, SUM(R.PSATF) PSATF, SUM(R.VTF) VTF
FROM TBC_QRCODEPOISE_REP R where R.WORKDATE>=TO_DATE(‘2018-02-25‘,‘yyyy-mm-dd‘) AND R.WORKDATE<=TO_DATE(‘2018-02-27‘,‘yyyy-mm-dd‘) GROUP BY R.ORGANNO, R.ORGANNAME) T ON A.ORGANNO = T.ORGANNO
WHERE A.ACCOUNTTYPE = ‘03‘ ORDER BY A.ORGANNO
三种方式有统计数据条数的差异,看是以实际数据,还是以费率表为主参照
标签:SQL
原文地址:http://blog.51cto.com/hebinteng/2094309