如何在 postgresql 中将文本 36 1/2 转换为 36.5
How to convert text 36 1/2 to 36.5 in postgresql
我有一个值为 36 1/2 的列,它存储为字符 varying.from postgresql 函数我需要将此文本转换为 36.5 以匹配我转换的实际 value.How在 postgresql 中向 36.5 发送文本“36 1/2”?
WITH f(n) AS
(SELECT *
FROM regexp_matches('36 1/2', '^([\d.]+)( +(\d+)/(\d+))*$'))
SELECT CASE
WHEN n[2] IS NULL
THEN n[1]::float8
ELSE n[1]::float8 + n[3]::float8 / n[4]::float8
END
FROM f;
我有一个值为 36 1/2 的列,它存储为字符 varying.from postgresql 函数我需要将此文本转换为 36.5 以匹配我转换的实际 value.How在 postgresql 中向 36.5 发送文本“36 1/2”?
WITH f(n) AS
(SELECT *
FROM regexp_matches('36 1/2', '^([\d.]+)( +(\d+)/(\d+))*$'))
SELECT CASE
WHEN n[2] IS NULL
THEN n[1]::float8
ELSE n[1]::float8 + n[3]::float8 / n[4]::float8
END
FROM f;