コラボレーションツール

join

 サービス名:  サイトURL:

SELECT
t1.month,
sum(t2.sales)
FROM
(SELECT to_char(g, 'YYYY-MM') AS MONTH
FROM generate_series('2021-04-01'::date, '2022-03-31', '1 day') AS g) AS t1
LEFT JOIN
(SELECT
sales_result_data.sales,
to_char(sales_result_data.date, 'YYYY-MM') AS MONTH
FROM sales_result_data
where sales_result_data."shopId" = 138) AS t2 ON t1.month = t2.month
GROUP BY t1.month;

https://images.microcms-assets.io/assets/f779624f18eb40b486f1fe37ed325c0d/88cf1cba4beb454683539753a976f687/ssss.jpeg