高级农民
- 积分
- 1051
- 大米
- 颗
- 鳄梨
- 个
- 水井
- 尺
- 蓝莓
- 颗
- 萝卜
- 根
- 小米
- 粒
- 学分
- 个
- 注册时间
- 2012-4-1
- 最后登录
- 1970-1-1
|
大概写了一下sql思路:
- 1.
- With recursive dates_tb as (
- Select.1point3acres
- min(Beg) as dates
- From
- subscriptions
- Union
- Select
- timestampadd(DAY, 1, dates) as dates
- From
- dates_tb
- Where
- dates < (select max(End) from subscriptions)
- )
- Select
- month(d.dates) as month_2019,
- count(distinct s.S) as n_subs
- From
- dates_tb d, subscriptions s
- Where
. Χ - s.state = ‘Paid’ and
- d.dates between Beg and End and
- d.dates between ‘2019-01-01’ and ‘2019-12-31’-baidu 1point3acres
- Group by
- month(d.dates)
- 2.
- select
- Year,. From 1point 3acres bbs
- Month,
- Country,
- State,
- product
- From. check 1point3acres for more.
- (select.--
- *,
- rank() over (partition by year, month, country, state order by n_subs desc) as prod_rnk
- From
- (Select
- year(d.dates) as year,
- month(d.dates) as month,
- s.product,
- s.state,
- s.country,
- count(distinct s.S) as n_subs
- From
- dates_tb d, subscriptions s
- Where
- s.state in (‘Paid’, ‘Trial’) and
- d.dates between Beg and End
- Group by
- year(d.dates),
- month(d.dates),
- s.product,
- s.state,. From 1point 3acres bbs
- s.country) a) b
- Where
- prod_rank >= 5
复制代码 |
|