请教年龄分段的 sql语句
dmtb:
xh nllow nlhigh nlfd
1 0 25 T25岁以下
2 26 30 T26—30岁
3 31 35 T31—35岁
...............
9 60 100 T60及岁以上
tbbase
xm nl gzdw
张三 33 单位1
李四 42 单位2
.......
王五 60 单位1
查询:
nlfd zs
T25岁以下 0
T26—30岁 0
T31—35岁 1
.....
T60及岁以上 1
SQL
[解决办法]
select nlfd,count(1) as zs from
dmtb,tbbase where nl between nllow and nlhigh
group by nlfd
select nlfd,count(1) as zs from
dmtb,tbbase where nl between nllow and nlhigh
group by nlfd
order by nlfd