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

Popular posts from this blog

C# random value from dictionary and tuple -

cgi - How do I interpret URLs without extension as files rather than missing directories in nginx? -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -