特斯拉电动汽车图片:vfp 数据统计问题

来源:百度文库 编辑:中科新闻网 时间:2024/04/28 04:58:25
我有两张表,表一字段:单位、性别、户粮关系;有10万多条记录。
表二字段:单位、男人数、女人数、农业人数、非农业人数。
现从表一中统计相关数据,并放到表二里,怎样编程能快点。

sele 单位,sum(性别="男") as 男人数,sum(性别="女") as 女人数,sum(户粮关系="农业") as 农业人数,sum(户粮关系="非农业") as 非农业人数 from 表一 into 表二 group by 单位

sele 1
use 表2
sele 2
use 表1 &&事先已建好按单位的索引
set order to 单位
go top
do while not eof()
x=单位
copy to temp while 单位=x &&将某单位的数据放到表新表temp中,然后对temp 进行统计
sele 3
use temp
select count(*) from temp where 性别='男' into array aa
select count(*) from temp where 性别='女' into array bb
use
sele 2
loca for 单位=x
repl 男人数 with aa(1),女人数 with bb(1)
sele 1
enddo