'SQL compilation error: syntax error line 1 at position 7 unexpected 'ROWS'

When I run the below query from snowflake web UI, Here is the error message:

select ROWS from "SNOWFLAKE"."ACCOUNT_USAGE"."METERING_HISTORY";

SQL compilation error: syntax error line 1 at position 7 unexpected 'ROWS'

When I do a

select * on the view, I am able to see the column 'ROWS'.



Solution 1:[1]

put the column name rows in quote, as it is a reserved name (ANSI reserved) , any reason why the column is called ROWS ?

select "ROWS" from tst1;

Solution 2:[2]

You have used ROWS which is a reserved keyword. You can use it when enclosed within quotes.

select "ROWS" from "SNOWFLAKE"."ACCOUNT_USAGE"."METERING_HISTORY";

You can refer to the below documentation for the reserved keywords list. https://docs.snowflake.com/en/sql-reference/reserved-keywords.html#reserved-limited-keywords

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Himanshu Kandpal
Solution 2 sprethepa