Commit 0377dbde authored by yindanlei's avatar yindanlei

add yeji_day report codes

parent d8cbef8d
......@@ -558,6 +558,43 @@ FULL JOIN
where partition_day>=REGEXP_REPLACE(trunc(date_sub(current_date(),8),'MM'),'-','')
AND partition_day <=regexp_replace(date_sub(current_date(),1),'-','')
group by SUBSTR(partition_day,1,8),merchant_id
UNION ALL
SELECT SUBSTR(t1.dt,1,8) as partition_date,merchant_id,sum(rechange) as chongzhi_amount,''all_amount,''cpc_amount,''cpc_chongzhi_amount,''cpc_click_num,''liulan_amount,''sixin_amount
FROM
(
SELECT
b.doctor_id,dt
,sum(rechange) as rechange --转诊充值消耗
FROM
(
SELECT account_id,abs(rechange) as rechange,REGEXP_REPLACE(SUBSTR(created_time, 1, 10), '-', '') as dt
FROM tl.tl_ap_account_accountflow--流水表
WHERE partition_day=regexp_replace(date_sub(current_date(),1),'-','')
and REGEXP_REPLACE(SUBSTR(created_time, 1, 10), '-', '')>=REGEXP_REPLACE(trunc(date_sub(current_date(),8),'MM'),'-','')
and REGEXP_REPLACE(SUBSTR(created_time,1,10),'-','')<=regexp_replace(date_sub(current_date(),1),'-','')
and type='16'--转诊消耗
)a
LEFT JOIN
(
SELECT id,doctor_id
FROM tl.tl_ap_account_account
WHERE partition_day=regexp_replace(date_sub(current_date(),1),'-','')
GROUP BY id,doctor_id
)b
on a.account_id=b.id
GROUP BY b.doctor_id,dt
)t1
LEFT JOIN
(
SELECT doctor_id,merchant_id
FROM online.ml_doctor_relation_dimen_day
WHERE partition_date = regexp_replace(date_sub(current_date(),1),'-','')
and doctor_is_merchant='true'
GROUP BY doctor_id,merchant_id
)t2
on t1.doctor_id=t2.doctor_id
GROUP BY SUBSTR(t1.dt,1,8),merchant_id
)gg
LEFT JOIN
(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment