SQL, subquery if null

2

I'm doing a query, but I did not want it to return NULL.

What I have 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 everything is fine but in increase not, does anyone know a solution?

    
asked by anonymous 14.11.2016 / 19:01

1 answer

1

ifnull has to be out of subquery :

ifnull((select ...), 0) as aumento
    
14.11.2016 / 19:21