sql 2005 区间数据统计

volkswageos volkswageos 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区


if object_id('tb') is not null
drop table tb
create table tb(type varchar(20),accessoryNo varchar(20),deviceNo varchar(10),lastTime decimal(27,6))
insert tb
select 'A','s10','z11',10 union all
select 'B','s10','z11',11 union all
select 'A','s11','z12',51 union all
select 'A','s10','z11',91 union all
select 'A','s10','z13',29 union all
select 'B','s10','z11',30 union all
select 'B','s10','z11',50 union all
select 'B','s10','z11',85 union all
select 'A','s10','z11',60 union all
select 'A','s10','z11',30 union all
select 'B','s10','z11',33

--要求的查询结果

/*

型别 合计 10以下 10-30 31-60 61-90 90以上
A 6 0 3 2 0 1
B 5 0 2 2 1 0
合计 11 0 5 4 1 1

*/

drop table tb

--查询语句应该怎么写呢?
...全文

相关推荐

评论 3
收藏 已收藏
分享
返回顶部
volkswageos
疑难问题 22,298 成员 121,727 内容