SELECT * FROM yy WHERE zjh ! in (SELECT zjh FROM zz) INTO CURSOR tmp
SELECT zz
APPEND FROM DBF('tmp')
SELECT a.* FROM yy a,zz b WHERE a.zjh==b.zjh AND a.dqrq-b.dqrq>3600 INTO tmp
SELECT zz
APPEND FROM DBF('tmp')
USE ZZ
COPY TO BAK
USE BAK
ALTER TABLE BAK ADD LY C(1)
REPLACE LY WITH "A" ALL
APPEND FROM YY
REPLACE LY WITH "B" FOR EMPTY(LY)
SELECT * FROM BAK ORDER BY ZJH,DQRQ DESC,LY INTO DBF PXXXK
CLOSE DATABASES ALL
DELETE FILE BAK.DBF
USE PXXXK
GOTO TOP
T_SJ=DATETIME()
T_ZJH=""
SCAN IF T_ZJH=ZJH THEN IF ABS(T_SJ-DQRQ)/60<30 THEN DELETE ELSE T_SJ=DQRQ ENDIF ELSE T_SJ=DQRQ T_ZJH=ZJH ENDIF
ENDSCAN
PACK
SELECT * FROM PXXXK WHERE LY='B' INTO DBF BAK
USE ZZ