,count (distinct case when cats(year,agecat)=20071 then id else . end) as y20071_idcnt ,count (distinct case when cats(year,agecat)=20072 then id else . end) as ...
SQL COUNT DISTINCT has been slow. It is, in essence, a grouping operation, which keeps traversed grouping field values for later comparisons. When the result set is too large, the data needs to be ...