MAK MAK - 1 year ago 198
SQL Question

PostgreSQL 9.3: Convert to float

I want to convert the calculated values into


My try 1:

SELECT float(SUM(Seconds))/-1323 AS Averag;

Gives me an error:

syntax error at or near "SUM"

My try 2:

SELECT to_float(SUM(Seconds))/-1323 AS Averag;

Gives me an error:

function to_float(bigint) does not exist

Answer Source

You need to use the cast syntax:

SELECT CAST (SUM(Seconds) AS FLOAT)/-1323 AS Averag;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download