select
sum(state) countOfOnes,
sum(decode(state, 0, 1, 0)) countOfZeros
from
productDetail
;
или
select
sum(state) countOfOnes,
count(*) - sum(state) countOfZeros
from
productDetail
;
или
select
state,
count(*) over (partition by state order by state) countOfState
from
productDetail
;
Первые два примера вернут одну строку с двумя столбцами:
countOfOnes countOfZeros
=========================
154 21
Третий пример вернет две строки с двумя столбцами, по одной строке на состояние.
state countOfState
=========================
0 21
1 154