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.
|