Bigquery - 两列内多个值的总和乘积
Bigquery - Sum Product of multiple value within two columns
我有这个值
我想计算一个新列,它将添加 ticket_units_count 和价格的乘积,因此它必须是:
5 * 33104.0 + 4 * 23449.0 = 259316
如何在 bigquery 中做到这一点?
我试过这个
SELECT
SUM(CAST(price AS FLOAT64) * CAST(ticket_units_count AS INT64))
FROM table
但它显示此错误:错误的双精度值:33104.0;23449.0
需要您的帮助来指定查询以获得预期的结果
考虑以下方法
select *,
( select sum(cast(_count as int64) * cast(_price as float64))
from unnest(split(ticket_units_count, ';')) _count with offset
join unnest(split(price, ';')) _price with offset
using (offset)
) as total
from your_table
如果应用于您问题中的示例数据 - 输出为
我有这个值
如何在 bigquery 中做到这一点? 我试过这个
SELECT
SUM(CAST(price AS FLOAT64) * CAST(ticket_units_count AS INT64))
FROM table
但它显示此错误:错误的双精度值:33104.0;23449.0 需要您的帮助来指定查询以获得预期的结果
考虑以下方法
select *,
( select sum(cast(_count as int64) * cast(_price as float64))
from unnest(split(ticket_units_count, ';')) _count with offset
join unnest(split(price, ';')) _price with offset
using (offset)
) as total
from your_table
如果应用于您问题中的示例数据 - 输出为