Usually, when I try to select multiple columns in SnowFlake and I forget to use comma (instead of a,b,c
I write a b c
), it gives me an error.
Input:
select a b c from (
SELECT column1 as c, column2 as a, column3 as b
FROM (VALUES ('Q','g','a'),('C','D','x'))
);
Output:
SQL compilation error: syntax error line 1 at position 11 unexpected 'c'.
But when I try to do this only between two columns, it does not raise any error, instead, it returns wrong result:
select a b from (
SELECT column1 as a, column2 as b, column3 as c
FROM (VALUES ('Q','g','a'),('C','D','x'))
);
Output:
It just shows single column, with values from column a
but says that it's column b
. I tried it several times on different warehouses, in different windows, with different names of columns and values, and it still does the same.
What is reason of such behavior? Why does it not raise error message same way as it does in case of 3 columns? I find this behavior very confusing. Can I somehow tell SF to raise error instead (just as in case with 3 or more columns)?