[英]SNOWFLAKE querying column name with Spaces
I am trying to use agg functions to query data, I have space in the column name in SNOWFLAKE我正在尝试使用 agg 函数来查询数据,我在 SNOWFLAKE 的列名中有空格
select item, avg(item price) from order group by item;
The error is错误是
Numerical value '1212.11' is not recognized
Expected output is预计 output 是
Code which gives item and avg price of that item给出项目和该项目的平均价格的代码
Try尝试
select item, try_to_number(avg("item price")) from order group by item; select item, try_to_number(avg("item price")) from order group by item;
If you try add " (double quotes) around the column name does that help?如果您尝试在列名周围添加 "(双引号),这有帮助吗?
select item, avg("item price"::INT) from order group by item;
The::INT just casts it to a datatype that can be summed. The::INT 只是将其转换为可以求和的数据类型。 You should take a peak at the datatypes available to find one that best suits your needs.您应该充分了解可用的数据类型,以找到最适合您需求的数据类型。 (2 dp might be good for currency) (2 dp 可能对货币有利)
Another possibility is:另一种可能性是:
select item, avg( price ) from order group by item;
That's if you don't have a column called "item price" rather 2 columns "item" and "price".那就是如果您没有名为“商品价格”的列,而是 2 列“商品”和“价格”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.