程序代码:
*vfp9.0
CREATE CURSOR tt (xh c(6),kcm c(8),kccj n(3),zxjxjhh d(8))
INSERT INTO tt VALUES ('0810704','大学英语',30, {^2010-11-1})
INSERT INTO tt VALUES ('0810704','大学英语',50,{^2010-12-1})
INSERT INTO tt VALUES ('0810704','计算机',20,{^2010-11-1})
INSERT INTO tt VALUES ('0810704','计算机',58,{^2010-12-1})
*方式1
SELECT * FROM tt WHERE kccj in (SELECT MAX(kccj) FROM tt GROUP BY kcm)
*方式2
select a.* from tt a,(SELECT kcm,MAX(kccj) kccj FROM tt GROUP BY kcm) b where a.kcm=b.kcm AND a.kccj=b.kccj
*vfp低版本7.0
SYS(3099)
select xh,kcm,zxjxjhh,max(kccj) kccj from tt group by kcm