当前位置:网站首页>MySQL面试真题(二十八)——案例-通讯运营商指标分析
MySQL面试真题(二十八)——案例-通讯运营商指标分析
2022-06-23 03:58:00 【Socialphobia_FOGO】
通讯运营商指标分析
现有表一:各城市用户ARPU值
表二:用户套餐费用表
业务要求:
1.各城市用户数、总费用(ARPU之和)是多少?
2.各城市用户arpu值表中各城市ARPU(0,30),[30,50),[50-80),[80以上)用户数分别是多少?
3.用户套餐费用表中用户有重复的记录,找出重复的用户
#1.各城市用户数、总费用(ARPU之和)是多少?
SELECT 城市,COUNT(DISTINCT 用户id) AS 各城市用户数,SUM(ARPU值) AS 总费用
FROM 各城市用户arpu值
GROUP BY 城市
结果如下:
#2.各城市用户arpu值表中各城市ARPU(0,30),[30,50),[50-80),[80以上)用户数分别是多少?
SELECT 城市,
SUM(CASE WHEN ARPU值>0 AND ARPU值<30 THEN 1 ELSE 0 END) AS '(0,30)用户数',
SUM(CASE WHEN ARPU值>=30 AND ARPU值<50 THEN 1 ELSE 0 END) AS '[30,50)用户数',
SUM(CASE WHEN ARPU值>=50 AND ARPU值<80 THEN 1 ELSE 0 END) AS '[50-80)用户数',
SUM(CASE WHEN ARPU值>=80 THEN 1 ELSE 0 END) AS '[80以上)用户数'
FROM 各城市用户arpu值
GROUP BY 城市
结果如下:
#3.用户套餐费用表中用户有重复的记录,找出重复的用户
SELECT 用户id
FROM 用户套餐费用表
GROUP BY 用户id
HAVING COUNT(用户id)>1
结果如下:
边栏推荐
- Xa mode explanation and code implementation of four Seata modes
- Qimen dunjia assistant decision software
- The road of architects starts from "storage selection"
- Jenkins installs and deploys and automatically builds and publishes jar applications
- 今日睡眠质量记录80分
- read 文件一个字节实际会发生多大的磁盘IO?
- 数学分析_笔记_第1章:集合与映射
- MySQL自定义序列数的实现
- What is the reason for the black screen of the computer monitor when the computer is turned on? What should I do about the black screen of the computer monitor
- Today's sleep quality record 80 points
猜你喜欢

What does the English letter PC mean? What does the Internet PC mean

树莓派assert初步使用练习

高等数学(第七版)同济大学 习题1-8 个人解答

Win软件 - (Net-Framework)已处理证书链,但是在不受信任提供程序信任的根证书中终止

Win11应用商店一直转圈解决办法

Design and implementation of spark offline development framework

数据库连接异常:create connection error, url: jdbc:mysql://ip/数据库名, errorCode 0, state 08S01问题处理

How to move the software downloaded from win11 app store to the desktop

Konva series tutorial 1:what is konva?

51万奖池邀你参战——第二届阿里云ECS CloudBuild开发者大赛来袭
随机推荐
Go language - use of packages
MCS: discrete random variable Bernoulli distribution
mysql字符集
Redis缓存穿透解决方案-布隆过滤器
高等数学(第七版)同济大学 习题1-8 个人解答
The road of architects starts from "storage selection"
Konva series tutorial 1:what is konva?
Database connection exception: create connection error, url: jdbc: mysql://ip/ Database name, errorcode 0, state 08s01 problem handling
Software project management 8.4 Software project quality plan
MCS:离散随机变量——Uniform分布
Pkav simple blasting
Common wireless charging and transmitting IC chips
Chapter IX app project test (1)
Fs2119a Synchronous Boost IC output 3.3V and fs2119b Synchronous Boost IC output 5V
啊哈C语言 第7章 有了它你能做更多的事(第27-28讲)
Stm32cube serial port uses dma+idle to receive variable length data
Ip6809 three coil 15W wireless charging transmitter scheme IC British chip
Special research on Intelligent upgrading of heavy trucks in China in 2022
Cloud native database is the world of future databases
How to move the software downloaded from win11 app store to the desktop