By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
| version |
|---|
| PostgreSQL 12.9 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-4), 64-bit |
6 rows affected
| product | code | coalesce | concat | to_char |
|---|---|---|---|---|
| Product_1 | 001 | 61 | month_0 | 2020-01 |
| Product_1 | 001 | 55 | month_1 | 2020-02 |
| Product_1 | 001 | 0 | month_2 | 2020-03 |
| Product_1 | 001 | 125 | month_3 | 2020-04 |
| Product_2 | 002 | 110 | month_0 | 2020-03 |
| Product_2 | 002 | 59 | month_1 | 2020-04 |