diff --git a/plugins/views_plugin_query_default.inc b/plugins/views_plugin_query_default.inc
index c30bb30..904dca8 100644
--- a/plugins/views_plugin_query_default.inc
+++ b/plugins/views_plugin_query_default.inc
@@ -1041,6 +1041,12 @@ class views_plugin_query_default extends views_plugin_query {
           }
           else {
             $has_condition = TRUE;
+            // DBTNG doesn't support to add the same subquery twice to the main
+            // query and the count query, so clone the subquery to have two instances
+            // of the same object.
+            if (is_object($clause['value']) && $clause['value'] instanceof SelectQuery) {
+              $clause['value'] = clone $clause['value'];
+            }
             $sub_group->condition($clause['field'], $clause['value'], $clause['operator']);
           }
         }
