一、背景说明
在移动运营商的业务中,用户会根据自己的需求选择不同的套餐,并且套餐通常有一定的使用期限。当套餐即将到期时,运营商会向用户发送应续订套餐的请求,用户可能会选择续订或不续订。通过计算用户的套餐续订率,可以了解用户对现有套餐的满意度和忠诚度,从而为运营商制定营销策略、优化套餐内容和服务提供数据支持。
二、问题描述
请编写一个SQL查询来查找每个用户的套餐续订率。其中,用户的“套餐续订率”是“成功续订套餐”的数量除以“应续订套餐的请求总数”,没有应续订套餐请求的用户的套餐续订率为 0。
本次以两种不同数据库进行分析和用例讲解,分别是梧桐数据库,oracle 。
三、表结构说明
- 梧桐数据库建表语句
简单的客户注册与套餐续订表主要字段。
create table customer_signups (
customer_id int primary key,
time_stamp date not null
);
create table subscription_confirm (
customer_id int,
time_stamp date,
response char(3),
primary key (customer_id, time_stamp)
);
2.oracle建表语句
简单的客户注册与套餐续订表主要字段。
create table customer_signups (
customer_id number primary key,
time_stamp date
);
create table subscription_confirm (
customer_id number,
time_stamp date,
response char(3

最低0.47元/天 解锁文章
1435





