PostgreSQL 使用 to_char 和 floor

PostgreSQL using to_char with floor

好的,我正在从 SQL 服务器转换到 PostgreSQL。我遇到了一些 to_char 的问题。

CASE LENGTH(LTRIM(RTRIM(to_char(floor(_FloatValue)))))
    WHEN 1 THEN '0' || LENGTH(LTRIM(RTRIM(TO_CHAR(floor(_FloatValue))))) || ':'
    ELSE LENGTH(LTRIM(RTRIM(TO_CHAR(FLOOR(_FloatValue))))) || ':'

我遇到了这个错误

   [2015-11-10 15:40:20] [42883] ERROR: function to_char(double precision) does not exist
   Hint: No function matches the given name and argument types. You might need to add explicit type casts.
   Where: PL/pgSQL function formatfloattohoursminutes(double precision) line 10 at RETURN

任何帮助都会很棒。

您似乎想在左边填充零:

select to_char(_FloatValue, '09.99');

http://www.postgresql.org/docs/current/static/functions-formatting.html#FUNCTIONS-FORMATTING-TABLE

http://www.postgresql.org/docs/current/static/functions-formatting.html#FUNCTIONS-FORMATTING-NUMERIC-TABLE