add batch remove batch split batch comment selection show hidden batches hide batch highlight batch
db<>fiddle
donate feedback about
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
WITH rentabilidade_fundos AS (
SELECT '2020-04-01' DATA, -0.25 fundo_conservador, -0.35 fundo_moderado, -0.45 fundo_arrojado
),

dias AS (
SELECT DATE_ADD('2020-04-01', INTERVAL rnk day) dia
FROM (SELECT row_number() over() -1 rnk
FROM information_schema.columns limit 31) gerado)


SELECT dias.dia, r.fundo_conservador, r.fundo_moderado, r.fundo_arrojado
from dias
LEFT OUTER JOIN rentabilidade_fundos r
ON r.data = dias.dia
where dias.dia BETWEEN '2020-04-01' AND '2020-04-31'
order by dias.dia


dia fundo_conservador fundo_moderado fundo_arrojado
2020-04-01 -0.25 -0.35 -0.45
2020-04-02 null null null
2020-04-03 null null null
2020-04-04 null null null
2020-04-05 null null null
2020-04-06 null null null
2020-04-07 null null null
2020-04-08 null null null
2020-04-09 null null null
2020-04-10 null null null
2020-04-11 null null null
2020-04-12 null null null
2020-04-13 null null null
2020-04-14 null null null
2020-04-15 null null null
2020-04-16 null null null
2020-04-17 null null null
2020-04-18 null null null
2020-04-19 null null null
2020-04-20 null null null
2020-04-21 null null null
2020-04-22 null null null
2020-04-23 null null null
2020-04-24 null null null
2020-04-25 null null null
2020-04-26 null null null
2020-04-27 null null null
2020-04-28 null null null
2020-04-29 null null null
2020-04-30 null null null