create cursor t2 (学号 c(4),姓名 c(8),课目 c(10),成绩 n(3)) insert into t2 values ("1001","张三","数学",102) insert into t2 values ("1001","张三","语文",120) insert into t2 values ("1002","李四","数学",119) insert into t2 values ("1002","李四","语文",108) insert into t2 values ("1003","王五","政治",101) insert into t2 values ("1003","王五","历史",105) select distinct 课目 from t2 into array ajg * 创建临时表结构及索引 lcstr="" for lnI=1 to alen(ajg,1) lcstr=lcstr+iif(empty(lcstr),"",",")+alltrim(ajg[lnI,1])+" N(3)" endfor create cursor t4 (学号 c(4),姓名 c(8),&lcstr) index on 学号+姓名 tag xhxm * 结束 [color=#808080]*[/color] * 数据处理 select t2 set relation to 学号+姓名 into "t4" scan km=alltrim(t2.课目) if found("t4") replace (km) with t2.成绩 in "t4" else insert into t4 (学号,姓名,&km) values (t2.学号,t2.姓名,t2.成绩) endif endscan set relation to select t4 set filter to alltrim(学号)=="1002" && 根据情况,这行代码可有可无 browse
[此贴子已经被作者于2017-8-25 12:18编辑过]