Skip to content
Advertisement

How to call a column named “group” in Snowflake?

I have a table in Snowflake with the following structure:

| id | group | subgroup |
_________________________ 
| 1  | verst | burg     |
| 2  | travel| plane    |
| 3  | rest  | bet      |

I need to call only the column “group”, so I tried the following code:

select t2.group
from  table as t2

but the following error arises

SQL compilation error: syntax error line 1 at position 7 unexpected 'group'. syntax error line 2 at position 0 unexpected 'from'.

I have also tried using:

select group
from  table as t2

select "group"
from  table as t2

but I always get the same error. I know I can call the whole table using * but the real table where I get this data from has many more columns and we want to display this data in a dashboard. Additionally, I am not the owner of the table since it is filled by a microservice, so I cannot change the column names and I can’t modify the microservice process. I would appreciate any suggestion.

Advertisement

Answer

Given the table could not be created without double quotes, you need to know how it was created to know how to refer to the column. Which is to say it the create code was CREATE TABLE awsome ("GrOuP" string); there you will need to type “GrOuP”

There is also a session setting to ignore case in double quotes that might help. see QUOTED_IDENTIFIERS_IGNORE_CASE

But by default things are upper case, thus try "GROUP"

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement