[英]AWS Athena: How can we get integer value as string with thousand comma separator in AWS Athena
我們如何用千位逗號分隔符顯示 integer 數字。
因此,通過執行以下語句
select * from 1234567890
我們怎樣才能得到結果為1,234,567,890
您可以通過將數字轉換為字符串並使用正則表達式來實現此目的:
with dataset(num) as (
values (1234567890),
(123456789),
(12345678),
(1234567),
(123456),
(12345),
(1234),
(123)
)
select regexp_replace(cast(num as VARCHAR), '(\d)(?=(\d\d\d)+(?!\d))', '$1,')
from dataset
Output:
_col0 |
---|
1,234,567,890 |
123,456,789 |
12,345,678 |
1,234,567 |
123,456 |
12,345 |
1,234 |
123 |
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.