Hello all in SQL we have to used a query to get a desired output as we want. sometimes we have to write a small and large query to get a same output.
i have a problem statement where i want to calculate a count of 1 in following table:
i want to calculate a count of sum.
>Solution :
With sample data you posted, one option is
SQL> with test (a, b, c, d) as
2 (select 1, 0, 0, 0 from dual union all
3 select 0, 1, 0, 0 from dual union all
4 select 0, 0, 1, 0 from dual union all
5 select 0, 0, 0, 1 from dual
6 )
7 select sum(a + b + c + d) result
8 from test;
RESULT
----------
4
SQL>
