I am struggling with a snowflake Database LEFT JOIN query with a date range. Please find the sample table contents below
My Snowflake SQL Query : SELECT O.ORDER_DATE, CASE WHEN ORDER_DATE IS NULL THEN 'NO' ELSE 'YES' END AS ORDER_PLACED, C.CUSTOMER_ID, C.NAME FROM CUSTOMER C LEFT JOIN ORDERS ON C.CUSTOMER_ID=O.CUSTOMER_ID AND O.ORDER_DATE >= DATEADD(DAY, -3, CURRENT_DATE)
The output I expect - I would like to get last 3 days records with all the customers and whether they made an order or not, something like below
The current data output I am getting with the given snowflake query is
I don't know if the problem is with the date range(I need the date range anyway), as i'm getting required results for the very first day. But for remaining days i'm only getting those records, when an order is placed. As shown in the expected result, i would like to get all the customer records with details like whether they made an order or not.
Thanks in advance