当前位置:网站首页>Real MySQL interview question (XXVIII) -- case - Analysis of indicators of communication operators
Real MySQL interview question (XXVIII) -- case - Analysis of indicators of communication operators
2022-06-23 05:40:00 【Socialphobia_ FOGO】
Index analysis of communication operators
Table 1 is available : Users in various cities ARPU value 
Table two : User package fee table 
Business requirements :
1. Number of users in each city 、 The total cost (ARPU The sum of the ) How much is the ?
2. Users in various cities arpu Cities in the value table ARPU(0,30),[30,50),[50-80),[80 above ) What are the number of users ?
3. Users have duplicate records in the user package expense table , Find duplicate users
#1. Number of users in each city 、 The total cost (ARPU The sum of the ) How much is the ?
SELECT City ,COUNT(DISTINCT user id) AS Number of users in each city ,SUM(ARPU value ) AS The total cost
FROM Users in various cities arpu value
GROUP BY City
give the result as follows :
#2. Users in various cities arpu Cities in the value table ARPU(0,30),[30,50),[50-80),[80 above ) What are the number of users ?
SELECT City ,
SUM(CASE WHEN ARPU value >0 AND ARPU value <30 THEN 1 ELSE 0 END) AS '(0,30) The number of users ',
SUM(CASE WHEN ARPU value >=30 AND ARPU value <50 THEN 1 ELSE 0 END) AS '[30,50) The number of users ',
SUM(CASE WHEN ARPU value >=50 AND ARPU value <80 THEN 1 ELSE 0 END) AS '[50-80) The number of users ',
SUM(CASE WHEN ARPU value >=80 THEN 1 ELSE 0 END) AS '[80 above ) The number of users '
FROM Users in various cities arpu value
GROUP BY City
give the result as follows :
#3. Users have duplicate records in the user package expense table , Find duplicate users
SELECT user id
FROM User package fee table
GROUP BY user id
HAVING COUNT( user id)>1
give the result as follows :
边栏推荐
- STM32cube CMSIS_ V2 FreeRTOS queue usage
- What does the English letter PC mean? What does the Internet PC mean
- 基于SSM框架的借阅图书管理系统
- Win11不能录制音频怎么办?Win11无法录入声音的解决方法
- B-string value (string DP) of the 16th Northeast College Students' Programming Competition (warm-up)
- Redis缓存穿透解决方案-布隆过滤器
- What does it mean to open more accounts? Why open more accounts? How to implement it safely?
- MCS:连续随机变量——LogNormal分布
- Webrtc[47] - a common way for webrtc to save YUV data
- visdom画多条动态损失曲线
猜你喜欢

Composite API

How much disk IO will actually occur for a byte of the read file?

Win11 app store keeps turning around solution

Qimen dunjia assistant decision software

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

Konva series tutorial 1:what is konva?

AI艺术的基因工程?使用 #Artbreeder 改变图像的任意形态

Leetcode 797: all possible paths

FS2119A同步升压IC输出3.3V和FS2119B同步升压IC输出5V

Face recognition determination threshold
随机推荐
After the idea code is developed, the code is submitted. If the branch is found to be incorrect after submission, how can I withdraw it
Win11应用商店一直转圈解决办法
MySQL面试真题(二十七)——RFM分析法对用户进行分类
View of MySQL introductory learning (III)
奇门遁甲辅助决策软件
MySQL面试真题(二十九)——案例-找到爱看的电影
About replay attack and defense
Go grouping & sorting
fastjson中的@JSONField注解
Face recognition determination threshold
What does the English letter PC mean? What does the Internet PC mean
Shutdown shutdown command
云原生大趋势下的容器化技术现状与发展
电脑开机显示器黑屏是什么原因,电脑显示器黑屏怎么办
App automated test appium advanced
Yingjixin ip6806 wireless charging scheme 5W Qi certified peripheral simplified 14 devices
Wechat applet: Star Trek spaceship ticket production and generation
Is there a real part-time job online? How do college students find part-time jobs in summer?
Markdown add background color to the picture
Wechat applet: production and generation of love guarantee