SELECT
SUM(totals.totalTransactionRevenue) *0.20 AS COGS
FROM `bigquery-public-data.google_analytics_sample.ga_sessions_*`
WHERE _TABLE_SUFFIX BETWEEN '20170701' AND '20170701';
为什么BigQuery会自动将创建的字段'Cost Of Goods Sold - COGS'转换为科学记数法? 以及如何修改此查询以将COGS拉为十进制格式值?
感谢。
答案 0 :(得分:3)
您可以使用新的数字/小数值来获取所需的格式:
SELECT cast(SUM(totals.totalTransactionRevenue) * 0.20 as numeric) AS COGS
它也适用于转换为字符串:
SELECT cast(SUM(totals.totalTransactionRevenue) * 0.20 as string) AS COGS