Answer the question
In order to leave comments, you need to log in
How to do round correctly in postgresql: ERROR: function round(double precision, integer) does not exist?
wrote a request
select
'request_median_duration' as metric_name,
EXTRACT(EPOCH FROM request_median_duration)/60 as metric_value,
TO_CHAR(NOW(), 'YYYY-MM-DD HH:MM:SS') as push_dttm
from mp_statistics
select
'request_median_duration' as metric_name,
ROUND(EXTRACT(EPOCH FROM request_median_duration)/60,2) as metric_value,
TO_CHAR(NOW(), 'YYYY-MM-DD HH:MM:SS') as push_dttm
from mp_statistics
SQL Error [42883]: ERROR: function round(double precision, integer) does not exist
Подсказка: No function matches the given name and argument types. You might need to add explicit type casts.
Позиция: 94
select
'request_median_duration' as metric_name,
ROUND(EXTRACT(EPOCH FROM request_median_duration)/60*100)/100 as metric_value,
TO_CHAR(NOW(), 'YYYY-MM-DD HH:MM:SS') as push_dttm
from mp_statistics
Answer the question
In order to leave comments, you need to log in
found a way to do type conversion via CAST
select
'request_median_duration' as metric_name,
round(cast(EXTRACT(EPOCH FROM request_median_duration)/60 as numeric),2) as metric_value,
TO_CHAR(NOW(), 'YYYY-MM-DD HH:MM:SS') as push_dttm
from mp_statistics
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question