Browse Source

sql优化

zhouzeyu@c-top.com.cn 3 years ago
parent
commit
b231f9fde1

+ 5 - 16
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/DailyReportMapper.xml

@@ -113,15 +113,8 @@
         FROM
         (
         SELECT
-        account_id accountId,
-        (
-        SELECT
-        auth_name
-        FROM
-        ctop_user_allocation
-        WHERE
-        account_id = t1.account_id
-        ) authName,
+        t1.account_id accountId,
+        t2.auth_name authName,
         stat_date statDate,
         campaign_name campaignName,
         unit_name unitName,
@@ -185,22 +178,18 @@
 
         FROM
         ctop_kuaishou_report_daily_group t1
+        INNER JOIN ctop_user_allocation t2 on t1.account_id=t2.account_id
         <where>
             <if test="date != null">
                 and stat_date = #{date}
             </if>
 
             <if test="accountIds != null">
-                and account_id in
-                <foreach collection="accountIds" item="item" separator=","
-                         open="(" close=")">
-                    #{item}
-                </foreach>
-
+                and t1.account_id =#{accountIds}
             </if>
         </where>
         GROUP BY unit_id
-        order by account_id
+        order by t1.account_id
 
         ) t1
     </select>