sql语句按分数段划分维度

编程入门 行业动态 更新时间:2024-10-26 14:27:26

sql语句按分数段划分<a href=https://www.elefans.com/category/jswz/34/1767143.html style=维度"/>

sql语句按分数段划分维度

统计各分数段的数据数量
select id,score,date_month,
case when score <5 then '0-5' 
when score>=5 and score <10 then '5-10'
when score>=10 and score <20 then '10-20'
when score>=20 and score <30 then '20-30'
when score>=30 and score <50 then '30-50'
when score>=50 then '50以上'
end as interzone
from table1 B
WHERE is_deleted = 0 AND date_month = 'XXX'
统计各分数段的数据数量(某分数段无数据也存在)
select t3.id,t3.date_month,t3.interzone,t4.XX_id from
((select DISTINCT id,date_month,interzone from (
(select interzone from XX_interzone) t1
inner join
(select id,date_month from tablea where is_deleted = 0) t2)) as t3
left join (
select id,XX_id,date_month,
case when score <5 then '0-5' 
when score>=5 and score <10 then '5-10'
when score>=10 and score <20 then '10-20'
when score>=20 and score <30 then '20-30'
when score>=30 and score <50 then '30-50'
when score>=50 then '50以上'
end as interzone
from tableb
where is_deleted = 0 ) as t4
on t3.interzone=t4.interzone and t3.id=t4.id and t3.date_month=t4.date_month)
WHERE t3.id = 'XXX' AND t3.date_month = 'XXX'

更多推荐

sql语句按分数段划分维度

本文发布于:2024-02-26 11:00:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1702246.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:维度   语句   分数   sql

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!