select sname from aa
where cj='優'
group by sname
having count(*)=(select max(icount) from (select count(*) icount from aa group by stime) as a)
借鑑上面的朋友,確實應該這樣寫
我在access也測試過了,並沒有報錯
elect sname from aa
where cj='優'
group by sname
having count(*)=(select max(icount) from (select count(*) as icount from aa group by stime) as a)
明白维什马报错了 我要的是整个纪录
而select sname from aa
where cj='優'
group by sname
having count(*)=(select max(icount) from (select count(*) as icount from aa group by stime) as a)
只给出了sname 而 sname是分组条件 这样的话只能查询 这个分组的集合如sum(stim) count(cj)等
这个查询不能查出每条记录
可以这样写
select * from aa where sname in(
select sname from aa
where cj='優'
group by sname
having count(*)=(select max(icount) from (select count(*) as icount from aa group by stime) as a))
但是效率太低
psynet123 你能还能改改吗?? 改好分就是你的了
昨天上不了網,你的要求裡面說的是查出符合條件的學生,而不是整條紀錄
如果要查出整條紀錄
select * from aa where sname in(
select sname from aa
where cj='優'
group by sname
having count(*)=(select max(icount) from (select count(*) as icount from aa group by stime) as a))