select a.count1-b.count2 from(select count(value1) count1 from tablename) a,(select count( distinct value2) count2 form tablename) b.