Index: wp-includes/query.php
===================================================================
--- wp-includes/query.php	(revision 3668)
+++ wp-includes/query.php	(working copy)
@@ -505,7 +505,6 @@
 		$result = '';
 		$where = '';
 		$limits = '';
-		$distinct = '';
 		$join = '';
 
 		if ( !isset($q['post_type']) )
@@ -822,15 +821,6 @@
 				$q['orderby'] = 'post_date '.$q['order'];
 		}
 
-		//$now = gmdate('Y-m-d H:i:59');
-		
-		//only select past-dated posts, except if a logged in user is viewing a single: then, if they
-		//can edit the post, we let them through
-		//if ($pagenow != 'post.php' && $pagenow != 'edit.php' && !($this->is_single && $user_ID)) {
-		//	$where .= " AND post_date_gmt <= '$now'";
-		//	$distinct = 'DISTINCT';
-		//}
-
 		if ( $this->is_attachment ) {
 			$where .= ' AND (post_type = "attachment")';
 		} elseif ($this->is_page) {
@@ -842,8 +832,6 @@
 
 			if ( is_admin() )
 				$where .= " OR post_status = 'future' OR post_status = 'draft'";
-			else
-				$distinct = 'DISTINCT';
 	
 			if ( is_user_logged_in() )
 				$where .= " OR post_author = $user_ID AND post_status = 'private'))";
@@ -884,11 +872,13 @@
 		// Apply post-paging filters on where and join.  Only plugins that
 		// manipulate paging queries should use these hooks.
 		$where = apply_filters('posts_where_paged', $where);
-		$groupby = " $wpdb->posts.ID ";
+		$groupby = '';
 		$groupby = apply_filters('posts_groupby', $groupby);
+		if ( ! empty($groupby) )
+			$groupby = 'GROUP BY ' . $groupby;
 		$join = apply_filters('posts_join_paged', $join);
 		$orderby = apply_filters('posts_orderby', $q['orderby']); 
-		$request = " SELECT $distinct * FROM $wpdb->posts $join WHERE 1=1" . $where . " GROUP BY " . $groupby . " ORDER BY " . $orderby . " $limits";
+		$request = " SELECT * FROM $wpdb->posts $join WHERE 1=1 $where $groupby ORDER BY $orderby $limits";
 		$this->request = apply_filters('posts_request', $request);
 
 		$this->posts = $wpdb->get_results($this->request);
Index: wp-includes/template-functions-links.php
===================================================================
--- wp-includes/template-functions-links.php	(revision 3668)
+++ wp-includes/template-functions-links.php	(working copy)
@@ -470,13 +470,13 @@
 	if (isset($max_num_pages)) return $max_num_pages;
 	
 	if ( 'posts' == get_query_var('what_to_show') ) {
-		preg_match('#FROM\s(.*)\sGROUP BY#siU', $wp_query->request, $matches);
+		preg_match('#FROM\s(.*)\sORDER BY#siU', $wp_query->request, $matches);
 		$fromwhere = $matches[1];
 		$numposts = $wpdb->get_var("SELECT COUNT(DISTINCT ID) FROM $fromwhere");
 		return ceil($numposts / get_option('posts_per_page'));
 	} else {
 		$posts = $wp_query->posts;
-		preg_match('#WHERE\s(.*)\sGROUP BY#siU', $wp_query->request, $matches);
+		preg_match('#WHERE\s(.*)\sORDER BY#siU', $wp_query->request, $matches);
 		$where = preg_replace('/( AND )?post_date >= (\'|\")(.*?)(\'|\")( AND post_date <= (\'\")(.*?)(\'\"))?/siU', '', $matches[1]);
 		$num_days = $wpdb->query("SELECT DISTINCT post_date FROM $wpdb->posts WHERE $where GROUP BY year(post_date), month(post_date), dayofmonth(post_date)");
 		return ceil($num_days / get_option('posts_per_page'));

