title: Invalid input syntax for type double precision: "null" when finding nearest city with longitude/latitude
body: <p>I have a table in a PostgreSQL database.</p>
  
  <p>Table Structure:</p>
  
  <pre><code>CREATE TABLE "public"."citydescription" (
      "srno" int4 DEFAULT nextval('newcitydescription_srno_seq'::regclass) NOT NULL,
      "cityname" varchar(40),
      "country" varchar(40),
      "airportcode" varchar(4),
      "description" text,
      "code" varchar,
      "parentcity" int4,
      "type" varchar DEFAULT 'city'::character varying,
      "title" varchar,
      "priority" varchar,
      "isactive" bool DEFAULT true,
      "sequence" int4,
      "latitude" varchar,
      "longitude" varchar,
      "score" float8,
      "state_province" varchar(2),
      "population" text,
      "isnew" bool,
      "has_banner" bool DEFAULT false,
      "hreflang" bool,
      "au_href" varchar,
      CONSTRAINT "newcitydescription_pkey" PRIMARY KEY ("srno")
  )
  WITH (OIDS=FALSE);
  </code></pre>
  
  <p>When I run this query:</p>
  
  <pre><code>SELECT * FROM (
      SELECT
          *,
          (
              3959 * acos(
                  cos( radians(6.414478) ) *
                  cos( radians( CAST(latitude AS FLOAT) ) ) *
                  cos( radians( CAST(longitude AS FLOAT) ) - radians(12.466646) ) +
                  sin( radians(6.414478) ) *
                  sin( radians( CAST(latitude AS FLOAT) ) )
              )
          ) AS distance 
          FROM citydescription
      ) al
  WHERE distance &lt; 5
  ORDER BY distance
  LIMIT 20;
  </code></pre>
  
  <p>It gives this error:</p>
  
  <blockquote>
    <p>[Err] ERROR: invalid input syntax for type double precision: "null"</p>
  </blockquote>
  
  <p>Note: There is no option to alter column type as this will lead to lots of code changes</p>