|
|
@@ -6,6 +6,7 @@
|
|
|
concat(round(if(ifnull(sum(real_cost_amount),0)=0, 0, (ifnull(sum(share_iaa_amount),0)+ifnull(sum(share_pay_amount),0))/sum(real_cost_amount)*100), 2), '%') AS real_roi,
|
|
|
ifnull(sum(cost_amount),0) AS cost_amount,
|
|
|
round(ifnull(sum(pay_amount), 0), 2) AS pay_amount,
|
|
|
+ ifnull(sum(share_iaa_amount), 0) as share_iaa_amount,
|
|
|
ifnull(sum(share_iaa_amount), 0) + ifnull(sum(share_pay_amount), 0) - ifnull(round(sum(real_cost_amount), 2), 0) AS real_profit,
|
|
|
ifnull(sum(iaa_amount), 0) + ifnull(sum(pay_amount), 0) - ifnull(sum(cost_amount), 0) AS water_profit,
|
|
|
ifnull(sum(share_iaa_amount), 0) + ifnull(sum(share_pay_amount), 0) as end_amount,
|
|
|
@@ -26,6 +27,7 @@
|
|
|
concat(round(if(ifnull(sum(real_cost_amount),0)=0, 0, (ifnull(sum(share_iaa_amount),0)+ifnull(sum(share_pay_amount),0))/sum(real_cost_amount)*100), 2), '%') AS real_roi,
|
|
|
ifnull(sum(cost_amount),0) AS cost_amount,
|
|
|
round(ifnull(sum(pay_amount), 0), 2) AS pay_amount,
|
|
|
+ ifnull(sum(share_iaa_amount), 0) as share_iaa_amount,
|
|
|
ifnull(sum(share_iaa_amount), 0) + ifnull(sum(share_pay_amount), 0) - ifnull(round(sum(real_cost_amount), 2), 0) AS real_profit,
|
|
|
ifnull(sum(iaa_amount), 0) + ifnull(sum(pay_amount), 0) - ifnull(sum(cost_amount), 0) AS water_profit,
|
|
|
ifnull(sum(share_iaa_amount), 0) + ifnull(sum(share_pay_amount), 0) as end_amount
|
|
|
@@ -41,34 +43,32 @@
|
|
|
) tb2
|
|
|
</select>
|
|
|
<select id="tmpTopMovie" resultType="java.util.Map">
|
|
|
- select case ot1.movie_source when 2 then movie_name else concat('欢瑞自制-', movie_name) end as movie_name,
|
|
|
- ot1.rk, ot1.share_end_amount, ot1.end_amount, ot2.cost_amount, ot2.real_cost_amount,
|
|
|
- concat(round(if(ifnull(cost_amount,0)=0, 0, end_amount/cost_amount*100), 2), '%') AS water_roi,
|
|
|
- concat(round(if(ifnull(real_cost_amount,0)=0, 0, share_end_amount/real_cost_amount*100), 2), '%') AS real_roi
|
|
|
- FROM
|
|
|
- (select ifnull(tb2.movie_name, tb1.movie_id) as movie_name, movie_source,
|
|
|
- rank() over (order by sum(end_amount) desc) as rk, sum(end_amount) as end_amount, sum(share_end_amount) as share_end_amount
|
|
|
+ select tb4.standard_movie_id, tb4.standard_movie_name as movie_name, group_concat(distinct case tb4.movie_source when 2 then 2 else 1 end) as movie_source,
|
|
|
+ rank() over (order by sum(end_amount) desc) as rk,
|
|
|
+ sum(share_end_amount) as share_end_amount, sum(end_amount) as end_amount, sum(cost_amount) as cost_amount, sum(real_cost_amount) as real_cost_amount,
|
|
|
+ concat(round(if(ifnull(sum(cost_amount),0)=0, 0, sum(end_amount)/sum(cost_amount)*100), 2), '%') AS water_roi,
|
|
|
+ concat(round(if(ifnull(sum(real_cost_amount),0)=0, 0, sum(share_end_amount)/sum(real_cost_amount)*100), 2), '%') AS real_roi
|
|
|
from
|
|
|
- (select
|
|
|
- ifnull(sum(iaa_amount), 0) + ifnull(sum(pay_amount), 0) as end_amount,
|
|
|
- ifnull(sum(share_iaa_amount), 0) + ifnull(sum(share_pay_amount), 0) as share_end_amount,
|
|
|
- movie_id
|
|
|
- from
|
|
|
- application.user_data_report_daily udrd
|
|
|
- where stat_date = ${date} and movie_id != '-9999'
|
|
|
- group by movie_id
|
|
|
- having ifnull(sum(share_iaa_amount), 0) + ifnull(sum(share_pay_amount), 0)>0
|
|
|
- order by end_amount desc
|
|
|
- ) tb1
|
|
|
+ (select product_id from application.media_product_report_daily where stat_date=${date}
|
|
|
+ union select movie_id from application.user_data_report_daily where stat_date=${date}) tb1
|
|
|
left join
|
|
|
- (select distinct moive_id, REGEXP_REPLACE(movie_name, '[^a-zA-Z一-龥]', '') as movie_name, movie_source from deepthink.all_moive) tb2 on tb1.movie_id=tb2.moive_id
|
|
|
- group by movie_name order by rk limit 10) ot1
|
|
|
+ (select product_id, round(ifnull(sum(cost_amount),0),2) as cost_amount, sum(real_cost_amount) as real_cost_amount
|
|
|
+ from application.media_product_report_daily where stat_date=${date}
|
|
|
+ group by product_id
|
|
|
+ ) tb2 on tb1.product_id=tb2.product_id
|
|
|
left join
|
|
|
- (select REGEXP_REPLACE(product_name, '[^a-zA-Z一-龥]', '') as product_name, round(ifnull(sum(cost_amount),0),2) as cost_amount, sum(real_cost_amount) as real_cost_amount
|
|
|
- from application.media_product_report_daily where stat_date=${date} group by REGEXP_REPLACE(product_name, '[^a-zA-Z一-龥]', '')
|
|
|
- ) ot2 on ot1.movie_name=ot2.product_name
|
|
|
- group by case ot1.movie_source when 2 then movie_name else concat('欢瑞自制-', movie_name) end
|
|
|
- order by rk
|
|
|
+ (select movie_id, ifnull(sum(iaa_amount), 0) + ifnull(sum(pay_amount), 0) as end_amount,
|
|
|
+ ifnull(sum(share_iaa_amount), 0) + ifnull(sum(share_pay_amount), 0) as share_end_amount
|
|
|
+ from application.user_data_report_daily where stat_date=${date}
|
|
|
+ group by movie_id
|
|
|
+ ) tb3 on tb1.product_id=tb3.movie_id
|
|
|
+ left join
|
|
|
+ (select moive_id, standard_movie_id, standard_movie_name, movie_source from deepthink.all_moive
|
|
|
+ ) tb4 on tb1.product_id=tb4.moive_id
|
|
|
+ where 1=1 and tb1.product_id!='-9999'
|
|
|
+ group by tb4.standard_movie_name
|
|
|
+ order by sum(end_amount) desc
|
|
|
+ limit 10
|
|
|
</select>
|
|
|
|
|
|
|