Answer the question
In order to leave comments, you need to log in
Is it possible to display several COUNTs with a condition in one selection?
Is it possible to do something like this in PL SQL:
Select
a,
b,
c,
COUNT (D ****** WHERE D = 'tino'),
COUNT (D ****** WHERE D = 'tipo' '),
COUNT (D ****** WHERE D = 'tiko')
FROM
TABLE A
JOIN TABLE B ON a.id = b.id
GROUP BY ******
In general, can COUNT somehow condition to work?
Or what are the alternative ways?
I need to display several quantities summed by conditions in one report (to sum only with codes 'tino', 'tipo' and 'tiko')
Answer the question
In order to leave comments, you need to log in
and take and just write, instead of asking?
COUNT does not count NULL
SELECT
key,
count(DECODE(value, 'tino',1, NULL)) AS tino,
count(DECODE(value, 'tipo',1, NULL)) AS tipo,
count(DECODE(value, 'tiko',1, NULL)) AS tiko
FROM table1
GROUP BY key
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question