I'm trying to do the following:
SELECT a.id_series, a.series_num, IFNULL (d.total, 0) DE (SUBCONSULTA) d LEFT JOIN fact_contability a ON a.id_serie = d.id_serie AND a.serie_num = d.serie_num
- The subquery is a very extended query of multiple nested selections where multiple tables are involved and I do not show it to make it clearer, so I leave a snippet of the subquery.
Serious_id | serie_num | name | total 2508 | 1 | Client1 | $ 20 2508 | 2 | Client1 | € 10 2508 | 4 | Client2 | $ 20
Now, I want to make a left join between this previous query and a table containing all the series, as follows:
Serious_id | serie_num | name 2508 | 1 | Client1 2508 | 2 | Client1 2508 | 3 | CUSTOMER2 2508 | 4 | CUSTOMER2
- The serial number = 3 does not appear in the previous one.
And the result should be:
Serious_id | serie_num | name | total 2508 | 1 | Client1 | $ 20 2508 | 2 | Client1 | € 10 2508 | 3 | Client1 | 0 € 2508 | 4 | Client2 | $ 20
I want to list all the series and if there is no line in the subquery, mark it with 0 €.
This is possible? I'm trying but I do not know where I'm failing.