i have table like this
id | name | planned_amount | actual | avail
1 ABC 100 123 100
2 DEF 200 345 200
3 uytuyn 9000 311 300
4 oiui 890 200 200
above data output from query like this:
select a.name,
e.planned_amount,
dd.sum as actual,
e.planned_amount - dd.sum as avail
from crossovered_budget_lines as e,
account_analytic_account as a,
(select analytic_account_id, sum(debit+credit)
from account_move_line
where date between '2021-01-01' and '2021-05-01'
group by analytic_account_id) as dd
where e.analytic_account_id = a.id
and dd.analytic_account_id = .id
limit 5
when range data from table account_move_line is null ( no output data ), i want to output like this, column actual give 0 value :
id | name | planned_amount | actual | avail
1 ABC 100 0 100
2 DEF 200 0 200
3 uytuyn 9000 0 300
4 oiui 890 0 200
how to query to produce the output above ? iam stuck , thanks
select ... dd.sum ...becomesselect coalesce(dd.sum, 0) ...JOINandLEFT JOINoperators