From 60b285b21e43b2f71ce9f53e9ec55a56055e5c51 Mon Sep 17 00:00:00 2001 From: wuaho Date: Wed, 21 Jul 2021 15:32:49 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=86=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 充值视图.sql | 13 ++++++++++--- 新用户视图.sql | 12 ++++++++++-- 新账号付费.sql | 23 +++++++++++++++++++++++ 活跃账号视图.sql | 11 +++++++++++ 4 files changed, 54 insertions(+), 5 deletions(-) create mode 100644 新账号付费.sql create mode 100644 活跃账号视图.sql diff --git a/充值视图.sql b/充值视图.sql index 02803bc..f32f0f6 100644 --- a/充值视图.sql +++ b/充值视图.sql @@ -1,6 +1,13 @@ +drop table if exists zhengba.recharge_game; create view zhengba.recharge_game as -select toDate(addHours(`#event_time`, 8)) as date, `#bundle_id`, owner_name, channel, sum(money) as money +select toDate(addHours(`#event_time`, `#zone_offset`)) as date, + `#os`, + `#bundle_id`, + owner_name, + channel, + arrayDistinct(groupArray(binduid)) as account, + length(account) as account_num, + sum(money) as money from zhengba.event where `#event_name` = 'rechargeGame' -group by toDate(addHours(`#event_time`, 8)), toDate(addHours(`#event_time`, 8)), `#bundle_id`, owner_name, channel -order by date \ No newline at end of file +group by toDate(addHours(`#event_time`, `#zone_offset`)), `#os`, `#bundle_id`, owner_name, channel \ No newline at end of file diff --git a/新用户视图.sql b/新用户视图.sql index 7064672..1359076 100644 --- a/新用户视图.sql +++ b/新用户视图.sql @@ -1,4 +1,12 @@ -create view zhengba.new_account as select toDate(addHours(`#event_time`,8)) as date, groupArray(`binduid`) as account,length(account) as num +drop table if exists zhengba.new_account; +create view zhengba.new_account as +select toDate(addHours(`#event_time`, `#zone_offset`)) as date, + `#os`, + `#bundle_id`, + owner_name, + channel, + groupArray(`binduid`) as account, + length(account) as num from zhengba.event where role_idx = 1 -group by toDate(addHours(`#event_time`,8)) \ No newline at end of file +group by toDate(addHours(`#event_time`, `#zone_offset`)), `#os`, `#bundle_id`, owner_name, channel \ No newline at end of file diff --git a/新账号付费.sql b/新账号付费.sql new file mode 100644 index 0000000..7bf7a80 --- /dev/null +++ b/新账号付费.sql @@ -0,0 +1,23 @@ +drop table if exists zhengba.new_account_recharge; +create view zhengba.new_account_recharge as (select date, + `#os`, + `#bundle_id`, + owner_name, + channel, + uniqExact(binduid) as accout_num, + sum(money) as money +from (select toDate(addHours(`#event_time`, `#zone_offset`)) as date, + `#os`, + `#bundle_id`, + owner_name, + channel, + binduid, + money + from zhengba.event + where `#event_name` = 'rechargeGame') as tb1 + left join (select toDate(addHours(`#event_time`, `#zone_offset`)) as date, + binduid + from zhengba.event + where role_idx = 1) as tb2 + on tb1.date = tb2.date and tb2.binduid = tb1.binduid +group by date, `#os`, `#bundle_id`, owner_name, channel) \ No newline at end of file diff --git a/活跃账号视图.sql b/活跃账号视图.sql new file mode 100644 index 0000000..260bd88 --- /dev/null +++ b/活跃账号视图.sql @@ -0,0 +1,11 @@ +drop table if exists zhengba.active_account; +create view zhengba.active_account as +select toDate(addHours(`#event_time`, `#zone_offset`)) as date, + `#os`, + `#bundle_id`, + owner_name, + channel, + uniqCombined(binduid) as num, + arrayDistinct(groupArray(binduid)) as account +from zhengba.event +group by toDate(addHours(`#event_time`, `#zone_offset`)), `#os`, `#bundle_id`, owner_name, channel \ No newline at end of file