How to use subquery in views where clause
Just ran into the same question, here is what I found:

You can add a sub query to your view using the hook_views_query_alter hook in a custom module (documentation). Inside the module you should add something like the following:

function your_module_views_query_alter(&amp;$view, &amp;$query) {
  if ( $view-&gt;current_display == '[display in question]'){
    $query-&gt;add_where_expression([group], [sub query]);
  }
}


documentation for $query->add_where_expression.  You can add whatever where clause you need using this function.

hook_views_query_alter should go in your_module.views.inc.  Make sure you declare hook_views_api in your_module.module, otherwise views wont know to look for the file. For example:

function your_module_views_api() { // declare your views api # here
  return array(
    'api' =&gt; 3,
  );
}