I have a header table and a transaction table. The header table has Id value Null and description has something and Transaction table having Id as null for description something.
Now when I join on Header.Id = Transaction.Id I should have Id having matching values as well as null value as id matching with null value in transaction table.
Like the below query:
SELECT
SH.HEADER_COLID,
SH.HEADER_COLDESCRIPTION,
S.SALEORDER_MONTH,
S.SALEORDER_YEAR,
SUM(S.SALEORDER_AMT),
SUM(S.SALEORDER_QTYCASES),
SUM(S.SALEORDER_QTYWGHTPNDS)
FROM SDS_HEADERS SH, SALEORDERS S
WHERE SH.HEADER_COLID = S.DIVISION
AND SH.COLUMN_ID =1
AND S.OPEN_CLOSE='false'
AND S.SALEORDER_YEAR='2021'
GROUP BY SH.HEADER_COLID, SH.HEADER_COLDESCRIPTION,
S.SALEORDER_MONTH, S.SALEORDER_YEAR
ORDER BY SH.HEADER_COLID, SH.HEADER_COLDESCRIPTION,
S.SALEORDER_MONTH, S.SALEORDER_YEAR ASC
I get matching records for SH.HEADER_COLID = S.DIVISION but Null value for HEADER_COLID should be matched against DIVISION null values but I am not getting these records. I need them please help on how to achieve this in snowflake.