Google BigQuery 查询转换点“.”逗号“,”

Google BigQuery Query to convert dot "." to comma ","

我有一个有效的查询(不是我创建的),但我想添加一种方法来转换一些带有点“.”的数字列。逗号“,”,因为我来自欧洲,无法在 Google 表格中使用点符号。

我需要从点“.”转换的列名逗号“,”以便能够在 Google 表格中将其用作数字:

item_price  
item_tax    
shipping_price  
shipping_tax    
gift_wrap_price 
gift_wrap_tax   
item_promotion_discount 
ship_promotion_discount

这是我的实际查询:

with raw as (
SELECT
amazon_order_id AS Ref_Commande,
TIMESTAMP(purchase_date) Date_Achat,
date(TIMESTAMP(purchase_date)) Date,
extract(hour from TIMESTAMP(purchase_date)) Heures,
extract(minute from TIMESTAMP(purchase_date)) Minutes,
extract(second from TIMESTAMP(purchase_date)) Secondes,
case when extract(dayofweek from TIMESTAMP(purchase_date)) = 1 then '7.Dimanche'
when extract(dayofweek from TIMESTAMP(purchase_date)) = 2 then '1.Lundi'
when extract(dayofweek from TIMESTAMP(purchase_date)) = 3 then '2.Mardi'
when extract(dayofweek from TIMESTAMP(purchase_date)) = 4 then '3.Mercredi'
when extract(dayofweek from TIMESTAMP(purchase_date)) = 5 then '4.Jeudi'
when extract(dayofweek from TIMESTAMP(purchase_date)) = 6 then '5.Vendredi'
when extract(dayofweek from TIMESTAMP(purchase_date)) = 7 then '6.Samedi'
end as jours,

TIMESTAMP(last_updated_date) Date_Update,
order_status AS Status_Commande,
fulfillment_channel AS Expediteur, 
sales_channel AS Marketplace,
product_name AS Ref_Articles,
sku AS SKU,
asin AS ASIN,
item_status AS Status_Expedition,
quantity AS Quantite_Articles,
item_price AS Montant_Articles,
item_tax AS Montant_TVA,
shipping_price AS Montant_Port,
shipping_tax AS Montant_TVA_Port,
gift_wrap_price AS Montant_Emballage_Cadeau,
gift_wrap_tax AS Montant_TVA_Emballage_Cadeau,
item_promotion_discount AS Montant_Promotion,
ship_promotion_discount AS Montant_Promotion_Port,
ship_city AS Ville,
ship_state AS Etat,
ship_postal_code AS Code_Postal,
ship_country AS Pays,
promotion_ids AS Ref_Promotion,
is_business_order AS Client_Business,
buyer_company_name AS Nom_Client_Business,
row_number() over (partition by amazon_order_id,sku order by last_updated_date desc) rn 
FROM
`rankup-271414.RANKUP.Hoopzi_Seller_FR_FlatFileAllOrdersReportbyLastUpdate`
)

select *
from raw
where rn = 1
and Marketplace != 'Non-Amazon'
and Status_Commande != 'Cancelled'
order by Date_Achat desc

如您在此示例中所见,我将点替换为逗号。

with numbers as (
 SELECT 123456.1 AS input UNION ALL
 SELECT 1234567.12 AS input UNION ALL
 SELECT 12345678.123 AS input
)
 
SELECT
 input,
 REPLACE(cast(input as string), '.', ',') as formatted
FROM numbers

在您的情况下,您将仅使用要更改点逗号的字段。喜欢这些例子:

 REPLACE(cast(item_price as string), '.', ',') as Montant_Articles
 REPLACE(cast(item_tax as string), '.', ',') as Montant_TVA
 REPLACE(cast(shipping_price as string), '.', ',') as Montant_Port
 REPLACE(cast(shipping_tax as string), '.', ',') as Montant_TVA_Port
 REPLACE(cast(gift_wrap_price as string), '.', ',') as Montant_Emballage_Cadeau
 REPLACE(cast(gift_wrap_tax as string), '.', ',') as Montant_TVA_Emballage_Cadeau
 REPLACE(cast(item_promotion_discount as string), '.', ',') as Montant_Promotion
 REPLACE(cast(ship_promotion_discount as string), '.', ',') as Montant_Promotion_Port

你可以看到结果。