anchor.diff:          #filtercheck{'=' = {_,_,{const,EqVal}}} when GtVal >= EqVal ->
               %% query like `a = 10 AND a > 10` cannot be satisfied
               throw({error, {impossible_where_clause, << >>}});
  +        #filtercheck{'=' = {_,_,{const,EqVal}}} when GtVal < EqVal ->
  +            %% query like `a = 10 AND a > 8` we can eliminate the greater than
  +            %% clause because if a to be 10 it must also be greater than 8
  +            {eliminate, Acc};
           #filtercheck{'>' = undefined} = Check1 ->
               %% this is the first equality check so just record it
               Check2 = Check1#filtercheck{'>' = F},
  
positive.code:         false ->
              {eliminate, Acc}
      end;
  check_where_clause_is_possible_fold(_, _, {'=',{field,FieldName,_},_} = F, Acc) ->
      case find_filter_check(FieldName, Acc) of
          #filtercheck{'=' = F} ->
              %% this filter has been specified twice so remove the second occurence
              {eliminate, Acc};
          #filtercheck{'=' = F_x} when F_x /= undefined ->
              %% there are two different checks on the same column, for equality
              %% this can never be satisfied.
  
negative.code:         compile(DDL, Q)
      ).
  
  greater_than_value_lower_than_equality_is_eliminated_test() ->
      DDL = get_ddl(
          "CREATE TABLE table1("
          "a TIMESTAMP NOT NULL, "
          "b SINT64 NOT NULL, "
          "PRIMARY KEY ((a),a))"),
      {ok, Q} = get_query(
          "SELECT * FROM table1 "
          "WHERE a = 5 AND b = 10 AND b > 5"),
      {ok, [S|_]} = compile(DDL, Q),
      ?assertPropsEqual(
          [{startkey,[{<<"a">>,timestamp,5}]},
           {endkey,  [{<<"a">>,timestamp,5}]},
           {filter, {'=',{field,<<"b">>,sint64},{const, 10}}},
           {end_inclusive,true}],
          S?SQL_SELECT.'WHERE'
      ).
  
  greater_than_value_lower_than_equality_is_eliminated_swap_lhs_rhs_test() ->
      DDL = get_ddl(
          "CREATE TABLE table1("
          "a TIMESTAMP NOT NULL, "
          "b SINT64 NOT NULL, "
          "PRIMARY KEY ((a),a))"),
      {ok, Q} = get_query(
          "SELECT * FROM table1 "
          "WHERE a = 5 AND b > 5 AND b = 10"),
      {ok, [S|_]} = compile(DDL, Q),
      ?assertPropsEqual(
          [{startkey,[{<<"a">>,timestamp,5}]},
           {endkey,  [{<<"a">>,timestamp,5}]},
           {filter, {'=',{field,<<"b">>,sint64},{const, 10}}},
           {end_inclusive,true}],
          S?SQL_SELECT.'WHERE'
      ).
  
  -endif.
  