Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Good Way to SELECT Max Occurence
IMHO This solution isn't enough.
Following query will return one row at most
"Akp" <abhishek1999_at_gmail.com> wrote in message
news:1118230547.760880.267140_at_z14g2000cwz.googlegroups.com...
> Is this what you are looking for ?
> ===================================
> select * from
> (select rownum rn,X.*
> from(select count(*) ct,student_id
> from student_enrollment
> group by student_id
> order by ct desc) X
> )Y
> where Y.rn=1;
> ===================================
whereas following query will may return more rows when there will be many students having maximal number of enrollments
> > select student_id,count(*) from student_enrollment
> > group by student_id
> > having count(*)=(select max(count(*)) from student_enrollment group by
> > student_id);
Received on Wed Jun 08 2005 - 07:11:55 CDT
![]() |
![]() |