使用GS Query()将文本值转换为数字

huangapple go评论62阅读模式
英文:

Use GS Query() to convert text value into a number

问题

考虑一个表格,其中列A是与列B相关联的实体。列B包含文本格式的数字(例如,3.0000是文本)。

我尝试了以下查询:

=QUERY(range_name,"SELECT A, VALUE(B)",0).

我还尝试了这个查询:

=QUERY(range_name,"SELECT A, B*1",0).

都不起作用。在Google表格中,我可以通过乘法(B*1)来转换它,但我更喜欢在查询中进行此操作。

有什么想法吗?我将SQL和Google表格标记为标签,尽管在GS中有很多SQL函数不起作用。

谢谢。

英文:

Consider a table, in which column A is an entity associated with column B. And column B contains numbers in text formats (e.g., 3.0000 is a text).

I've tried this query:

=QUERY(range_name,"SELECT A, VALUE(B)",0). 

I've also tried this query:

=QUERY(range_name,"SELECT A, B*1",0).

Neither works. I'm able within google sheets to convert it by multiplying (B*1), but I'd prefer to do this within the query.

Any ideas? I'm tagging SQL as well as google sheets, though quite a few SQL functions don't work in GS.

Thanks.

答案1

得分: 0

=QUERY({A:A,INDEX(VALUE(B:B)}, "选择 Col1, Col2", 0)

显然,如果你只需要数据而不需要进一步处理,你可以去掉 "选择 Col1, Col2" 部分。

英文:

If you do it inside the range?

=QUERY({A:A,INDEX(VALUE(B:B))},"Select Col1, Col2",0)

Obviously if you just need the data without any further processing, you can get rid of "Select Col1, Col2" part

huangapple
  • 本文由 发表于 2023年2月13日 23:51:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/75438214.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定