How to use hook_views_query_alter to add field with no table in Drupal 7 Views 3
I had the same problem. And I've solved it.

    function ModuleName_views_query_alter(&amp;$view, &amp;$query) {
  if ($view-&gt;name == 'my_view' &amp;&amp; 'my_block_name' == $view-&gt;current_display)) {


    $formula = "3956 * 2 * ASIN(SQRT(POWER(SIN(($postcode_lat - abs(lat))*pi()/180/2),2) + COS($postcode_lat * pi()/180) * COS(abs(lat) * pi()/180) * POWER(SIN(($postcode_lng - lng) * pi()/180/2),2)))";

    // Sets the formula's alias.
    $query-&gt;add_field(NULL, $formula, 'distance');
    $query-&gt;add_where(0, "$formula &lt; 500", array(), 'formula');

    // Sets the order by reference
    $query-&gt;orderby = array(
      array(
        'field' =&gt; 'distance',
        'direction' =&gt; 'ASC',
      )
    );
  }
}


See http://roldanarts.com/2013/11/22/diego-f-roldan/blog/using-formulas-views-hook-views-query-alter for more details.