소스 검색

‘增加环比’

zhl 3 년 전
부모
커밋
298147232b
1개의 변경된 파일7개의 추가작업 그리고 1개의 파일을 삭제
  1. 7 1
      Apietl/kwai_etl/Q4Task/AppKuaishouAccountReportBusi.py

+ 7 - 1
Apietl/kwai_etl/Q4Task/AppKuaishouAccountReportBusi.py

@@ -40,6 +40,8 @@ bei.user_id,
 bei.leader_id,
 bei.org_code,
 report.charge,
+ratio.charge last_charge,
+round((report.charge-ratio.charge)/ratio.charge*100,3) charge_ratio,
 report.`show`,
 report.photo_click,
 report.aclick,
@@ -321,7 +323,11 @@ LEFT JOIN `jeecg-boot`.user_company uc ON uc.user_id = cua.user_id
 LEFT JOIN `jeecg-boot`.ctop_product product ON product.id = cp.product_id
 WHERE
 cua.account_id IS NOT NULL) bei 
-ON report.account_id = bei.account_id;
+ON report.account_id = bei.account_id
+LEFT JOIN  (select advertiser_id account_id,round(sum(charge),3) charge from `media_api`.kuaishou_account_report_daily a  
+where stat_date between date_format(date_sub(date_format(date_sub({date_time}, INTERVAL 7 DAY),'%Y%m%d'), INTERVAL {day_count}-1 DAY),'%Y%m%d') and date_format(date_sub({date_time}, INTERVAL {day_count} DAY),'%Y%m%d') 
+group by advertiser_id) ratio
+ON report.account_id = ratio.account_id;
             """.format(date_time=self.date_time, day_count=self.day_count)
             TidbConn.upsert(conn=self.conn, sql_buff=sql)
             self.conn.commit()