select
case
when 金額 < 1000 then
金額
when 金額 < 1000000 then
concat(
truncate(金額/1000,0),',',right(金額,3)
)
when 金額 < 1000000000 then
concat(
truncate(金額/1000000,0),','
, right(concat('00',mod(truncate(金額/1000,0),1000)),3) ,','
,right(金額,3)
)
end as 金額
from `取引データ`