FIX: Combination of GROUP BY with HAVING Clause and LEFT OUTER JOIN with Derived Table Produces Incorrect Result (308458)



The information in this article applies to:

  • Microsoft SQL Server 2000 (all editions) 8.0

This article was previously published under Q308458
BUG #: 355244 (SHILOH_BUGS)

SYMPTOMS

If all of the following conditions are true for a query, extra rows may return for certain data sets:

  • You include GROUP BY and HAVING clauses.

  • You use a LEFT OUTER JOIN.

  • You incorporate derived tables.

  • You use an aggregate.

CAUSE

The optimizer inappropriately processes a cross join.

RESOLUTION

To resolve this problem, obtain the latest service pack for Microsoft SQL Server 2000. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

290211 INF: How to Obtain the Latest SQL Server 2000 Service Pack

WORKAROUND

To work around the problem, you can rewrite the query so that not all the conditions listed in the "Symptoms" section are true. For example, you can separate the long query into several simple queries.

STATUS

Microsoft has confirmed that this is a problem in Microsoft SQL Server 2000.

This problem was first corrected in Microsoft SQL Server 2000 Service Pack 2.

Modification Type:MajorLast Reviewed:10/16/2003
Keywords:kbbug kbfix KB308458