sql server - Count(*) the total unique entries but for 2 different fields -
i'm working on old table using sql server 2005. (the table isn't designed well, can't changed now.)
i'm trying count unique entries in 2 columns.
this gives list need:
select name1 mytable union select name2 mytable -- automatically removes dups
but how count that? (hopefully 1 statement.) this, syntax isn't right:
select count(select name1 mytable union select name2 mytable)
use subquery:
select count(*) (select name1 mytable union select name2 mytable) u
Comments
Post a Comment