当前位置:网站首页>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
结果如下:
边栏推荐
- [opencv450] inter frame difference method
- Current situation and development of containerization technology under the cloud native trend
- Win软件 - (Net-Framework)已处理证书链,但是在不受信任提供程序信任的根证书中终止
- App automated test appium advanced
- Management system of borrowed books based on SSM framework
- JVM原理之完整的一次GC流程
- Mobile phone wireless charging dual coil 15W scheme SOC IC ip6809
- How to move the software downloaded from win11 app store to the desktop
- Konva series tutorial 1:what is konva?
- Differences between fs4059a and fs5080e charging chips
猜你喜欢

Current situation and development of containerization technology under the cloud native trend

visdom的使用

Cloud native database is the world of future databases

SIFT feature point extraction

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

STC 32位8051单片机开发实例教程 一 开发环境搭建

云原生数据库是未来数据库的天下

Export PDF with watermark

Win11应用商店下载的软件怎么移到桌面

ArcTime 制作中英文字幕视频
随机推荐
Win11应用商店一直转圈解决办法
Mobile phone wireless charging dual coil 15W scheme SOC IC ip6809
英集芯推出4串锂电池100W移动电源升降压方案SoC芯片IP5389
账号多开是什么意思?为什么要账号多开?如何安全实现?
@jsonfield annotation in fastjson
GO语言-panic和recover
牛B程序员在“创建索引”时都会注意啥?
MCS:离散随机变量
QT QWidget nesting relative position acquisition (QT drawing nesting)
WebRTC[47] - WebRTC 保存 YUV 数据的常用方式
Common wireless charging and transmitting IC chips
STC 32 Bit 8051 Single Chip Computer Development Example Tutorial one development environment
STM32 clock tree misconfiguration causes boot to enter hard interrupt
阿里云对象存储oss+picgo+typora实现构建图床
Mysql入门学习(三)之视图
Introduction to MySQL (II) sub query + Association
When I was young, I thought my father was omnipotent
hash---------history
About information disclosure and defense
高等数学(第七版)同济大学 习题1-9 个人解答