skip to Main Content

Starting from question : [][1] and the last answer to it naturally arises the question what is the result of "select cast(2.000 as varchar);" ( don’t execute it before answering on your own). Where in the docs is it explained ?

To me the result is unexpected !!!

Answer without executing the statement, so we can check what is the "feeling" of people!



  1. From the manual:

    The CAST syntax conforms to SQL; the syntax with :: is historical
    PostgreSQL usage.

    Login or Signup to reply.
  2. It’s a postgres-style of casting, and it is mentioned in their docs:

    Without executing the query you posted, I’d expect the double 2.000 to be converted to a string… which has serious implications because "2.000" > "10" === true.

    EDIT: the above link points to an old version of postgres, but it’s still valid and it is what came up when I did a quick google search. Here is the link to the latest docs, the same syntax is still documented:

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top