用replace语句行不行?

如何把年龄字段里的记录都加1,并且后面对应的年龄分布阶段变为1?例如:
[ 本帖最后由 Kerberos 于 2014-1-17 09:50 编辑 ]

想学好VFP,想做VFP高手,想帮助更多的人解决VFP问题!
***生成临时表 Select * From 岗位分类表 Into Cursor temp Readwrite ***所有年龄加1岁 Replace 年龄 With Transform(Val(年龄)+1) All ***统计替换各年龄段方法1,但意义不大 Replace All 小于35 With Iif(Val(年龄)<36,"1",""),; 介于36至45 With Iif(Between(Val(年龄),36,45),"1",""),; 介于46至55 With Iif(Between(Val(年龄),46,55),"1",""),; 大于56 With Iif(Val(年龄)>55,"1","") Browse ***统计查询各年龄段人数,这样就足够了,其实不需要上面的replac Select Count(*) 总人数,Sum(Iif(Val(年龄)<36,1,0)) As "小于35",; sum(Iif(Val(年龄)>=36 And Val(年龄)<=45,1,0)) As "介于36至45", ; SUM(Iif(Between(Val(年龄),46,55),1,0)) As 介于46至55 ,; SUM(Iif(Val(年龄)>55,1,0)) As 大于56 ; FROM temp ***统计替换各年龄段方法2,但意义不大 Replace 小于35 With "1" For Val(年龄)<36 Replace 介于36至45 With "1" For Between(Val(年龄),36,45) REPLACE 介于36至45 With "1" For Val(年龄)>=36 AND Val(年龄)<=45 Replace 介于46至55 With "1" For Between(Val(年龄),46,55) Replace 大于56 With "1" For Val(年龄)>55
[此贴子已经被作者于2024-8-8 14:49编辑过]