hook_views_pre_execute() query not running (or being overwritten)
The reason nothing's changing is because you're just running db_query(), not actually assigning it to anything. If memory serves you need to assign your new query to $view-&gt;build_info['query'] (but that might be for Drupal 6). 

Also you won't unfortunately be able to use a vanilla db_query for this (as far as I know), because Views is expecting a db_select() object.

You can test this pretty easily by running the following two statements:

// Breaks the view.
$view-&gt;build_info['query'] = db_query('SELECT nid FROM {node}');

// Does not break the query (but results are wrong obviously).
$view-&gt;build_info['query'] = db_select('node', '')-&gt;fields('n', array('nid'));


I would look at re-working your query into a dynamic db_select() and then assigning it as in the above example, you should get more joy.