I am new to SnowFlake and exploring new things every day. I am stuck with the below scenario.
SELECT
'{COL}' AS field_name,
a.{COL}AS old_value,
b.{COL}AS new_value FROM A JOIN B ON(...)
WHERE a.{COL} != b.{COL}
I want to parameterize COL. And it may have multiple values like COL=col1,col2,col3. And then I want 3 queries separated by UNION as shown below.
SELECT
'col1' AS field_name,
a.col1 AS old_value,
b.col1 AS new_value FROM A JOIN B ON(...)
WHERE a.col1 != b.col1
UNION ALL
SELECT
'col2' AS field_name,
a.col2 AS old_value,
b.col2 AS new_value FROM A JOIN B ON(...)
WHERE a.col2 != b.col2
UNION ALL
SELECT
'col3' AS field_name,
a.col3 AS old_value,
b.col3 AS new_value FROM A JOIN B ON(...)
WHERE a.col3 != b.col3
Is there any way to achieve this in SnowSQL ( SnowFlake )?