I need to retrieve two different results from the same table, and combine them into a single result set. I'm using aggregate functions to generate reports on some data, and each column has different "where" conditions.
select sum(price)
as lucro_esperado
from tasks
where extract(month from enddate) = 12
AND extract(year from enddate) = 2019
and
select count(*)
as tarefas_abertas
from tasks
where extract(month from date_added) = 12
AND extract(year from date_added) = 2019
Since all I'm interested in this case are the aggregate functions results, I'm unable to use Join statements (as there's no ON condition), and Union ones will complain about different data types, as it's trying to wrongfully merge both aggregate results into a single column. Any other way I can achieve this, without having to query the database twice from my Node.js endpoint, and combining them manually?