2
I’m doing a query, but I didn’t want it to return NULL.
What I got is this:
select ifnull(sum(job_withdraw_qty),0) as total,
(
select IFNULL(sum(job_withdraw_qty),0)
from job_positions
where DATE_FORMAT(job_positions.created_on, '%Y-%m-%d') > '2016-01-01'
and is_hired = 1
and jobs.job_origem = 730
) as aumento
from job_positions
inner join jobs
on job_positions.job_id = jobs.job_id
where DATE_FORMAT(job_positions.created_on, '%Y-%m-%d') > '2016-01-01'
and is_hired = 1
Only when executing the query:
In the total field all is well but in the increase no, someone knows a solution?
the
ifnull
has to stay out of parenthesis:ifnull(select ...), 0) as aumento
– Sorack