------解决方案-------------------- with tb (名称, 金额) as
(
select 'a', 1 union all
select 'a', 11 union all
select 'a' , 8
)
, tb2 as
(
select *, case when 金额 < 10 then 0 else 1 end as z from tb
)
select 名称, SUM(金额) from tb2
group by 名称,z
------解决方案--------------------
那就没办法用groupby来做了,只能用遍历查找计算了。 ------解决方案-------------------- a 1
a 2
a 3
a 4
a 7
a 11
a 5
a 6
如果是这样结果是什么呢?
select mc,LEN(je) as 位,SUM(je) as 总额 from (
select 'a' as mc, 1 as je union select 'a',8 union select 'a',11)t
group by mc,LEN(je)
/*
mc 位 总额
a 1 9
a 2 11
*/