程序代码:
*01替换成思想政治,02替换成语文,03替换成数学,05替换成物理,11替换成外语(英语)
*只有一个字符型字段,且字段宽带为2,无法在原表替换,而且用原表替换也不符合数据安全,结果写入临时表tmp,也可以改为dbf表
SELECT *,SPACE(12) kmmc FROM 座号贴 INTO CURSOR tmp READWRITE &&临时表tmp
SCAN
DO CASE
CASE kmdm='01'
REPLACE kmmc WITH '思想政治'
CASE kmdm='02'
REPLACE kmmc WITH '语文'
CASE kmdm='03'
REPLACE kmmc WITH '数学'
CASE kmdm='05'
REPLACE kmmc WITH '物理'
CASE kmdm='11'
REPLACE kmmc WITH '外语(英语)'
ENDCASE
ENDSCAN
GO TOP
BROWSE &&查看tmp临时表情况
SELECT kmdm,kmmc,COUNT(*) 计数 FROM tmp GROUP BY 1,2 &&查看计数情况
*或者用12月28日帖子中schtg回复的语句,他这个速度快
SELECT *,SPACE(12) kmmc FROM 座号贴 INTO CURSOR tmp READWRITE &&临时表tmp
BROWSE
UPDATE tmp SET kmmc = ICASE(ALLTRIM(kmdm)=="01","思想政治",;
ALLTRIM(kmdm)=="02","语文",;
ALLTRIM(kmdm)=="03","数学",;
ALLTRIM(kmdm)=="05","物理",;
ALLTRIM(kmdm)=="11","外语(英语)")
GO TOP
BROWSE &&查看tmp临时表情况
SELECT kmdm,kmmc,COUNT(*) 计数 FROM tmp GROUP BY 1,2 &&查看计数情况
涉及大量数据,比较好的方式是按二楼说的,提前建立维护好“课程代码表”,需要的时候
SELECT *,SPACE(12) kmmc FROM 座号贴 INTO CURSOR tmp READWRITE &&临时表tmp
UPDATE tmp from 课程代码表 as b SET kmmc=b.kmmc WHERE tmp.kmdm=b.kmdm
[此贴子已经被作者于2025-1-6 14:32编辑过]