select count(case when treeName like '1%' then 1 else 0 end) '业务1统计', count(case when treeName like '1-1%' then 1 else 0 end) '业务2统计', count(case when treeName like '1-2%' then 1 else 0 end) '业务3统计' from table
我上面的不对,应该是 select count(case when treeName like '1%' then 1 else null end) '业务1统计', count(case when treeName like '1-1%' then 1 else null end) '业务2统计', count(case when treeName like '1-2%' then 1 else null end) '业务3统计' from tableoracle的
个数 p_code treeCode treeName
1 0 010 新业务1
0 010 01001 新业务1-1
3 01001 0100101 新业务1-1-1
1 01001 0100102 新业务1-1-2
0 01001 0100103 新业务1-1-2
0 010 01002 新业务1-2
1 01002 0100201 新业务1-2-1
1 01002 0100202 新业务1-2-2
count(case when treeName like '1-1%' then 1 else 0 end) '业务2统计',
count(case when treeName like '1-2%' then 1 else 0 end) '业务3统计'
from table
select count(case when treeName like '1%' then 1 else null end) '业务1统计',
count(case when treeName like '1-1%' then 1 else null end) '业务2统计',
count(case when treeName like '1-2%' then 1 else null end) '业务3统计'
from tableoracle的
他们都是可变的