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

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

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