Browse Source

修改sql

yumeng 5 years ago
parent
commit
c9ee70ea1f

+ 32 - 34
module-report/src/main/java/cn/com/ctop/bytedance/mapper/xml/MaterialReportMapper.xml

@@ -472,87 +472,85 @@
 
 
     <select id="selectDayMaterialList" parameterType="Map" resultType="com.alibaba.fastjson.JSONObject">
     <select id="selectDayMaterialList" parameterType="Map" resultType="com.alibaba.fastjson.JSONObject">
         SELECT
         SELECT
-        sum(charge) cost, -- 花费
-        sum(photo_show) photoShow, -- 封面曝光数
-        sum(photo_click) photoClick, -- 封面点击数
-        sum(aclick) aclick, -- 素材曝光数
-        sum(bclick) bclick, -- 行为数
+        sum(t1.charge) cost, -- 花费
+        sum(t1.photo_show) photoShow, -- 封面曝光数
+        sum(t1.photo_click) photoClick, -- 封面点击数
+        sum(t1.aclick) aclick, -- 素材曝光数
+        sum(t1.bclick) bclick, -- 行为数
         (case
         (case
-        when sum(photo_show) != 0
-        then (sum(photo_click) / sum(photo_show))
+        when sum(t1.photo_show) != 0
+        then (sum(photo_click) / sum(t1.photo_show))
         else 0
         else 0
         end
         end
         ) photoClickRatio, -- 封面点击率
         ) photoClickRatio, -- 封面点击率
 
 
         (case
         (case
-        when sum(aclick) != 0
-        then (sum(bclick) / sum(aclick))
+        when sum(t1.aclick) != 0
+        then (sum(t1.bclick) / sum(t1.aclick))
         else 0
         else 0
         end
         end
         ) actionRatio, -- 行为率
         ) actionRatio, -- 行为率
 
 
         (case
         (case
-        when sum(photo_show) != 0
-        then ((sum(charge) / sum(photo_show)) * 1000)
+        when sum(t1.photo_show) != 0
+        then ((t1.sum(charge) / sum(t1.photo_show)) * 1000)
         else 0
         else 0
         end
         end
         ) impression1kCost, -- 均千次封面曝光花费
         ) impression1kCost, -- 均千次封面曝光花费
 
 
         (case
         (case
-        when sum(photo_click) != 0
-        then (sum(charge) / sum(photo_click))
+        when sum(t1.photo_click) != 0
+        then (sum(t1.charge) / sum(t1.photo_click))
         else 0
         else 0
         end
         end
         ) photoClickCost, -- 平均封面点击单价
         ) photoClickCost, -- 平均封面点击单价
 
 
         (CASE
         (CASE
-        WHEN sum(photo_click) != 0
-        THEN (sum(charge) / sum(photo_click))
+        WHEN sum(t1.photo_click) != 0
+        THEN (sum(t1.charge) / sum(t1.photo_click))
         ELSE 0
         ELSE 0
         end
         end
         ) actionCost, -- 平均行为单价
         ) actionCost, -- 平均行为单价
 
 
         (case
         (case
-        WHEN sum(form_count) != 0
-        THEN sum(form_count)
-        WHEN sum(activation) != 0
-        THEN sum(activation)
+        WHEN sum(t1.form_count) != 0
+        THEN sum(t1.form_count)
+        WHEN sum(t1.activation) != 0
+        THEN sum(t1.activation)
         ELSE 0
         ELSE 0
         END
         END
         ) conversions, -- 转化数
         ) conversions, -- 转化数
 
 
         (
         (
         CASE
         CASE
-        WHEN sum(form_count) != 0
-        THEN (sum(charge) / sum(form_count))
-        WHEN sum(activation) != 0
+        WHEN sum(t1.form_count) != 0
+        THEN (sum(t1.charge) / sum(t1.form_count))
+        WHEN sum(t1.activation) != 0
         THEN (sum(charge) / sum(activation))
         THEN (sum(charge) / sum(activation))
         ELSE 0
         ELSE 0
         END
         END
         ) conversionPrice, -- 转化单价
         ) conversionPrice, -- 转化单价
 
 
-        ( SELECT url from ctop_kuaishou_video_get WHERE signature = signature limit 1) url,
-        signature signature, -- 视频md5
-        account_id accountId
+        ( SELECT url from ctop_kuaishou_video_get WHERE signature = t1.signature limit 1) url,
+        t1.signature signature, -- 视频md5
+        t1.account_id accountId
         from
         from
-        ctop_kuaishou_report_daily_creative
-        where  account_id in
+        ctop_kuaishou_report_daily_creative t1
+        where  t1.account_id in
         <foreach item="item" index="index" collection="accountIds"
         <foreach item="item" index="index" collection="accountIds"
                  open="(" separator="," close=")">
                  open="(" separator="," close=")">
             #{item}
             #{item}
         </foreach>
         </foreach>
-
-
         <if test="startDate != null">
         <if test="startDate != null">
-            and stat_date &gt;= #{startDate}
+            and t1.stat_date &gt;= #{startDate}
         </if>
         </if>
 
 
         <if test="endDate != null">
         <if test="endDate != null">
-            and stat_date &lt;= #{endDate}
+            and t1.stat_date &lt;= #{endDate}
         </if>
         </if>
-        and signature is not null
-        GROUP BY signature
-        order by sum(charge) desc
+        and t1.signature is not null
+        GROUP BY t1.signature
+        order by sum(t1.charge) desc
         limit 100
         limit 100
     </select>
     </select>