Weather Observation Station 19

  • + 0 comments

    I am using this query but getting error can anyone help

    WITH sorted_lat AS ( SELECT lat_n FROM station ORDER BY lat_n ASC ), counting AS ( SELECT COUNT(*) AS total_count FROM station ) SELECT ROUND( CASE WHEN total_count % 2 != 0 THEN (SELECT lat_n FROM sorted_lat LIMIT 1 OFFSET total_count / 2) ELSE ( (SELECT lat_n FROM sorted_lat LIMIT 1 OFFSET (total_count / 2) - 1) + (SELECT lat_n FROM sorted_lat LIMIT 1 OFFSET total_count / 2) ) / 2 END, 4 ) FROM counting;