with A_CODE as
(select 'JACK' namea, '2' a, '1' b from dual
union all
select 'JACK' namea, '3' a, '2' b from dual
union all
select 'JACK' namea, '1' a, '3' b from dual
union all
select 'TOM' namea, '1' a, '1' b from dual
union all
select 'TOM' namea, '2' a, '2' b from dual
union all
select 'TOM' namea, '4' a, '3' b from dual
union all
select 'SAM' namea, '2' a, '1' b from dual
union all
select 'SAM' namea, '2' a, '2' b from dual)
根据namea分组 求a/b 的值分别在0-1和1-2的列count值
plsql SQL
------解决方案--------------------
这样?
with A_CODE as
(select 'JACK' namea, '2' a, '1' b
from dual
union all
select 'JACK' namea, '3' a, '2' b
from dual
union all
select 'JACK' namea, '1' a, '3' b
from dual
union all
select 'TOM' namea, '1' a, '1' b
from dual
union all
select 'TOM' namea, '2' a, '2' b
from dual
union all
select 'TOM' namea, '4' a, '3' b
from dual
union all
select 'SAM' namea, '2' a, '1' b
from dual