视图
This commit is contained in:
parent
76c25d994c
commit
b1504650ee
13
充值视图.sql
Normal file
13
充值视图.sql
Normal file
@ -0,0 +1,13 @@
|
||||
drop table if exists shjy.recharge_game;
|
||||
create view shjy.recharge_game as
|
||||
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 shjy.event
|
||||
where `#event_name` = 'rechargeGame'
|
||||
group by toDate(addHours(`#event_time`, `#zone_offset`)), `#os`, `#bundle_id`, owner_name, channel
|
55
数据总览.sql
Normal file
55
数据总览.sql
Normal file
@ -0,0 +1,55 @@
|
||||
drop table if exists shjy.overview;
|
||||
create view shjy.overview as
|
||||
(
|
||||
select date,
|
||||
`#os`,
|
||||
`#bundle_id`,
|
||||
owner_name,
|
||||
channel,
|
||||
active_num,
|
||||
new_account_num,
|
||||
pay_account_num,
|
||||
money,
|
||||
new_account_recharge.accout_num as new_pay_account_num,
|
||||
new_account_recharge.money as new_money
|
||||
-- round(pay_account_num / active_num, 2) as pay_rate,
|
||||
-- round(money / pay_account_num, 2) as arppu,
|
||||
-- round(money / active_num, 2) as arpu,
|
||||
-- round(new_money / new_pay_account_num, 2) as new_arppu,
|
||||
-- round(new_money / new_account_num, 2) as new_arpu
|
||||
|
||||
from (select date,
|
||||
`#os`,
|
||||
`#bundle_id`,
|
||||
owner_name,
|
||||
channel,
|
||||
active_num,
|
||||
new_account_num,
|
||||
account_num as pay_account_num,
|
||||
money
|
||||
from (select date,
|
||||
`#os`,
|
||||
`#bundle_id`,
|
||||
owner_name,
|
||||
channel,
|
||||
num as active_num,
|
||||
new_account.num as new_account_num
|
||||
from shjy.active_account
|
||||
left join shjy.new_account
|
||||
on
|
||||
active_account.date = new_account.date and
|
||||
active_account.`#bundle_id` = new_account.`#bundle_id` and
|
||||
active_account.`#os` = new_account.`#os` and
|
||||
active_account.owner_name = new_account.owner_name and
|
||||
active_account.channel = new_account.channel) as tb1
|
||||
left join shjy.recharge_game on
|
||||
tb1.date = recharge_game.date and
|
||||
tb1.`#bundle_id` = recharge_game.`#bundle_id` and
|
||||
tb1.`#os` = recharge_game.`#os` and
|
||||
tb1.owner_name = recharge_game.owner_name and
|
||||
tb1.channel = recharge_game.channel) as tb2
|
||||
left join shjy.new_account_recharge on tb2.date = new_account_recharge.date and
|
||||
tb2.`#bundle_id` = new_account_recharge.`#bundle_id` and
|
||||
tb2.`#os` = new_account_recharge.`#os` and
|
||||
tb2.owner_name = new_account_recharge.owner_name and
|
||||
tb2.channel = new_account_recharge.channel)
|
12
新用户视图.sql
Normal file
12
新用户视图.sql
Normal file
@ -0,0 +1,12 @@
|
||||
drop table if exists shjy.new_account;
|
||||
create view shjy.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 shjy.event
|
||||
where role_idx = 1
|
||||
group by toDate(addHours(`#event_time`, `#zone_offset`)), `#os`, `#bundle_id`, owner_name, channel
|
23
新账号付费.sql
Normal file
23
新账号付费.sql
Normal file
@ -0,0 +1,23 @@
|
||||
drop table if exists shjy.new_account_recharge;
|
||||
create view shjy.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 shjy.event
|
||||
where `#event_name` = 'rechargeGame') as tb1
|
||||
left join (select toDate(addHours(`#event_time`, `#zone_offset`)) as date,
|
||||
binduid
|
||||
from shjy.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)
|
11
活跃账号视图.sql
Normal file
11
活跃账号视图.sql
Normal file
@ -0,0 +1,11 @@
|
||||
drop table if exists shjy.active_account;
|
||||
create view shjy.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 shjy.event
|
||||
group by toDate(addHours(`#event_time`, `#zone_offset`)), `#os`, `#bundle_id`, owner_name, channel
|
Loading…
Reference in New Issue
Block a user