L
L
Lavern8282020-08-07 15:18:47
PostgreSQL
Lavern828, 2020-08-07 15:18:47

What can be used in a SQL query?

Is it possible to get the names of tasks and the number of executions (label 'done'), as well as the number of rejections (label 'refused') using 1 request. So far, it has only been possible to display the names of the tasks and only the number of completions/rejections. It was not possible to display 3 parameters at the same time ...

spoiler
5f2d46968f77c372184073.png
5f2d469f6f9ed730934810.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Melkij, 2020-08-07
@Lavern828

Easier

select _task, 
count(*) filter(where _status = 'done') as done_cnt,
count(*) filter(where _status = 'refused') as refused_cnt
from test
where _status in ('done', 'refused')
group by _task;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question