select distinct(UserName), case when (column1 <> column2 OR (column1 IS NULL AND column2 IS NOT NULL) OR (column1 IS NOT NULL AND column2 IS NULL)) then Count(column3) else '0' end as Count from table1 where column4='test' Group BY column1 , column2, UserName
select column3 as UserName, Sum(case when (column4 <> column5 OR (column4 IS NULL AND column5 IS NOT NULL) OR (column4 IS NOT NULL AND column5 IS NULL)) then 1 else 0 end) as Count from table1 where column1='test' group by column3
select UserName,sum(Count) as Count from table1 group by UserName
select Column3 as UserName,Count(1) as Count from table1 Where isnull(column4,'')<>isnull(column5,'') group by Column3
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)