Tuesday, January 6, 2009

[mssql] How to count records with distinct option?

SELECT
(SELECT count(*) FROM
(SELECT DISTINCT City, Gender
FROM Database1..Person (NOLOCK)
WHERE Age > 18
UNION
SELECT DISTINCT City, Gender
FROM Database2..Person (NOLOCK)
WHERE Age > 18) x)

No comments:

Post a Comment