按年龄段分组显示列表数据(如:1~20)

 Select 0,       
 CASE WHEN BLA05  between 0 and 50 THEN '0~50' WHEN BLA05 between 50 and 100 THEN '50~100' END   F1,
        Count(distinct p.Xzqh+p.jgdm+BLA01+cast(BLA02 as varchar(50))) F2,
        sum(case when isnull(a,'')<>'' then 1 else 0 end) F3

        From Ks k     Where p.a=1
        Group by (CASE WHEN BLA05  between 0 and 50 THEN '0~50' WHEN BLA05 between 50 and 100 THEN '50~100' END)

你可能感兴趣的:(数据)