时间:2021-07-01 10:21:17 帮助过:43人阅读
SELECT device_id, coalesce(DATEDIFF(CONCAT(pt, " 00:00:00"), CONCAT(‘{partition}‘, ‘ 00:00:00‘), ‘dd‘), -1) as age FROM basic_data_center.extract_ttgame_extra_app_source__userdaystat WHERE pt in ( SUBSTR(DATEADD(TO_DATE(‘{partition}‘, ‘yyyy-mm-dd‘), 1, ‘dd‘), 1, 10), SUBSTR(DATEADD(TO_DATE(‘{partition}‘, ‘yyyy-mm-dd‘), 2, ‘dd‘), 1, 10), SUBSTR(DATEADD(TO_DATE(‘{partition}‘, ‘yyyy-mm-dd‘), 3, ‘dd‘), 1, 10), SUBSTR(DATEADD(TO_DATE(‘{partition}‘, ‘yyyy-mm-dd‘), 7, ‘dd‘), 1, 10), SUBSTR(DATEADD(TO_DATE(‘{partition}‘, ‘yyyy-mm-dd‘), 14, ‘dd‘), 1, 10), SUBSTR(DATEADD(TO_DATE(‘{partition}‘, ‘yyyy-mm-dd‘), 30, ‘dd‘), 1, 10) ) and day_age != 0) as b on a.device_id = b.device_id
SQL 常用方法函数
标签:app HERE 格式转化 tga 一个 pre partition ted cat