我的数据库表字段如下:
xh 学号
kcID 课程ID
kscs 考试次数
zhcj 综合成绩
....
我想找出一个学号(xh)中考试次数(kscs)为最大的记录。
select * from yourtable as tmp where kscs=(select max(kscs) from yourtable where xh=tmp.xh)
select * from cjzb a
where exists(select * from (SELECT MAX(kscs) kscs,kcid FROM cjzb WHEER xh='100000' GROUP BY kcID) b where a.kcid=kcid and a.kscs=kscs and a.xh='100000' )
select a.* from cjzb a ,(SELECT MAX(kscs) kscs,kcid FROM cjzb WHEER xh='100000' GROUP BY kcID) b
where xh='100000' and a.kscs=b.kscs and a.kcid =b.kcid