CLOSE DATABASES
USE 考勤表1
BLANK FIELDS 病假,事假,旷工,出差,年休 ALL
LOCAL bj ,sj ,kg,hj,cc,nx as Integer
&& 病假/事假/旷工/婚假/出差/年休
LOCAL ii as Integer
&& 1-31天
LOCAL fieldname ,fieldVal as String
STORE 0 TO bj ,sj ,kg,hj,cc,nx
SELECT 考勤表1
&& 假定前面已经use 了这张表
GO TOP
SCAN
FOR ii =1 TO 31
fieldname = "J" + LTRIM(STR(ii))
fieldVal = &fieldname
DO CASE
CASE fieldVal = '病'
bj = bj + 1
CASE fieldVal = '事'
sj = sj + 1
CASE fieldVal = '旷'
kg = kg + 1
CASE fieldVal = '婚'
hj = hj + 1
CASE fieldVal = '差'
cc = cc + 1
CASE fieldVal = '年'
nx = nx + 1
ENDCASE
ENDFOR
REPLACE 病假 WITH bj ,事假 WITH sj , 旷工 WITH kg ,婚假 WITH hj ,出差 WITH cc , 年休 WITH nx , ;
合计 WITH
bj +sj +kg +hj +cc + nx
STORE 0 TO bj ,sj ,kg,hj,cc,nx
ENDSCAN
MESSAGEBOX('完毕.',64,'考勤统计')
BROWSE
SELECT BM,COUN(病假) AS 病假人数,COUN(事假) AS 事假人数,COUN(旷工) AS 旷工人数 FROM 考勤表1 GROUP BY BM INTO TABLE LS_TABL
USE LS_TABL
BROW
[此贴子已经被作者于2019-12-12 21:40编辑过]