View Single Post
  #3 (permalink)  
Old 07-02-2007, 05:09 AM
MapGeek MapGeek is offline
Junior Member
 
Join Date: Jun 2007
Location: Northern California
Posts: 5
MapGeek is on a distinguished road
Default ANY answer. Re: How to COUNT records in UNION?

Yes, that's what I thought of first and tried immediately. But it generates a syntax error. The problem is UNION. This works:

SELECT COUNT(*) FROM (SELECT ...)

where the subquery is simple. Use UNION in the subquery, though, and it chokes.

Is this possibly a SQL Server/T-SQL-specific problem? I can't find any clarification on MS's SQL Server Books Online, but they give no SELECT examples incorporating a subquery with UNION like this.
Reply With Quote