标签:bin count Sessions 柱状图 duration 93 total 每一题 select
题93:
根据下表写一个SQL查询来报告(访问时长区间,会话总数),结果可用任何顺序呈现。
其中:决定统计访问时长区间分别为 “[0-5>”, “[5-10>”, “[10-15>” 和 “15 or more” (单位:分钟)的会话数量,并以此绘制柱状图。
其中:session_id 是该表主键,duration 是用户访问应用的时间, 以秒为单位。
解题思路:用union将每个区间连接,统计每个区间的个数即可。
select '[0-5>' bin,count(duration) total
from Sessions
where duration < 300
union
select '[5-10>' bin,count(duration) total
from Sessions
where duration >= 300 and duration < 600
union
select '[10-15>' bin,count(duration) total
from Sessions
where duration >= 600 and duration < 900
union
select '15 or more' bin,count(duration) total
from Sessions
where duration > 900;
标签:bin,count,Sessions,柱状图,duration,93,total,每一题,select 来源: https://blog.csdn.net/Txixi/article/details/122764951
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。