with median as
(select lat_n, row_number () over (order by lat_n asc) as row_asc,row_number () over (order by lat_n desc) as row_desc
from station
)
select round(avg(lat_n),4)
from median
where abs(row_asc-row_desc) <= 1
ERROR 1690 (22003) at line 1: BIGINT UNSIGNED value is out of range in '(median.row_asc - median.row_desc)'
while doin the same in postgresql the error shows-
ERROR: function round(double precision, integer) does not exist
LINE 7: select round(avg(lat_n),4)
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
SQL state: 42883
Character: 152
Hi any solution to this where I need to change
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Uday DodiyaRank #239 · 10.3K reputationPosted Sep 19, 2022, 1:55 AM EDT
Try This
With Median As (Select lat_n, row_number () over (order by lat_n asc) as row_asc,row_number () over (order by lat_n desc) As row_desc From Station) Select Round(Cast(Avg(lat_n) as int), 4) From Median Where Abs(row_asc-row_desc) <= 1Rajanikant HawaldarRank #110 · 20.2K reputationPosted Sep 14, 2022, 4:19 AM EDT
Try casting the double precision to int like below
round(cast(avg(lat_n) as int), 4)