Skip to content
Advertisement

Fraction formatting as halves or one third or quarters in PostgreSQL

I have some double-precision values in a column in PostgreSQL as following:

I want to round these values to their nearest quarter value at the decimal place. That is:

I saw this kind of feature in MS Excel. It can be found at: ]

How can I do the same in PostgreSQL? Thanks in advance for your help.

Advertisement

Answer

You can use arithmetic:

Here is a db<>fiddle.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement