7 years/100,000 miles. xyz $1200 abc 451.00| hhh 14.00
如何在Postgresql中获得输出= 1665。我要添加带 $ 符号的数字或带小数点的数字。
答案 0 :(得分:1)
with data(str) as (
values ('7 years/100,000 miles. xyz $1200 abc 451.00| hhh 14.00 ')
)
select sum(item::numeric)
from (
select unnest(regexp_matches(str, '(\d+\.\d+)|\$(\d+)', 'g')) as item
from data
) s
sum
---------
1665.00
(1 row)
的信息