How to add subquery in views to remove particular type of rows? I have applied join to users table with node_revision table like below:
function custom_overrides_views_data_alter(&amp;$data) {

  $data['users']['node_revision'] = array(
    'title' =&gt; t('Users revisions authored'),
    'help' =&gt; t('Relate a user to their revisions'),
    'relationship' =&gt; array(
      'base' =&gt; 'node_revision',
      'base field' =&gt; 'uid',
      'relationship field' =&gt; 'uid',
      'handler' =&gt; 'views_handler_relationship',
      'label' =&gt; t('revisions bubbla'),
    ),
  );
}

And by creating view now I got number of revisions per user like below:

Westerberg (15752)
Eriksson (4305)
Jakob (4182)
Andersson (4153)

But now I want to remove those revisions which are created when user created node first time ie: will only show edits but not the revisions which are created first time when new node was created. To solve this logic is to remove nodes having below true:
excluding the “first time created” nodes (original node revision)
node.created = node_revision.timestamp 

I tried using query alter but it uses quotes around field please suggest how to remove that ?
if ($view-&gt;name == &quot;my_view&quot;) {

    $sub_query = db_select('node', 'n')
      -&gt;fields('n', array('created'))
      -&gt;condition('n.created', 'node_revision_users.timestamp');


    $view-&gt;query-&gt;where[1]['conditions'][] = array(
      'field' =&gt; 'node_revision_users.timestamp',
      'value' =&gt; $sub_query,
      'operator' =&gt; 'NOT IN'
    );

  }

Output problem is like screenshot:

Please suggest! thanks
You should use where() to match table columns instead of condition

if ($view-&gt;name == "my_view") {
    $sub_query = db_select('node', 'n')
      -&gt;fields('n', array('created'))
      -&gt;where("n.created = node_revision_users.timestamp");

      $view-&gt;query-&gt;where[1]['conditions'][] = array(
        'field' =&gt; 'node_revision_users.timestamp',
        'value' =&gt; $sub_query,
        'operator' =&gt; 'NOT IN'
      );
}


Update  

Why where() not condition()

Syntax for condition:

$query-&gt;condition($field, $value = NULL, $operator = '=')


shows condition() is for building standard condition fragement

Syntax for where:

$query-&gt;where($snippet, $args = array())


shows where() is for building any arbitrary SQL as conditional fragment.

$snippet may contain any legal SQL fragment.