-- groupby+case select sum(j), sum(r) from ( select COUNT(distinct case vote when 'J' then id else null end) j, COUNT(distinct case vote when 'R' then id else null end) r from vote group by convert(char(8),regdate,112) ) a -- where+group by Select (select SUM(j) from ( select COUNT(distinct id) J from vote where convert(varchar(8),regdate,112) >= '20130130' and vote='J' gro..