Answer the question
In order to leave comments, you need to log in
How to solve problem with round in python (PostgreSQL)?
The round function does not work up to a specific decimal point.
cursor.execute(f"SELECT round(cash,0) FROM users WHERE id = 694973241827000421")
cursor.execute(f"SELECT round(cash,0) FROM users WHERE id = 694973241827000421")
psycopg2.errors.UndefinedFunction: function round(double precision, integer) does not exist
LINE 1: SELECT round(cash,0) FROM users WHERE id = 69497324182700042...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
Answer the question
In order to leave comments, you need to log in
Perhaps because round with precision only accepts the numeric type, while your cash has the double precision type.
Cast cash to numeric and try rounding.
Or do not specify the rounding precision, then you can leave dp.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question