Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> Re: A NEWBIE QUESTION ON SQL
In article <SUt05.5286$907.114458_at_newsread2.prod.itd.earthlink.net>,
"Muralidhar Prabhakaran" <muralip_at_earthlink.net> wrote:
> Try this
> Select per_no,max(acc_att)
> from tab
> group by per_no
won't work if they want percentage, then you are back to:
> > select *
> > from T
> > where acc_attempt = ( select max(acc_attempt)
> > from t t2
> > where t2.per_no = t.per_no )
> > /
> "Thomas J. Kyte" <tkyte_at_us.oracle.com> wrote in message
> news:8htinb$qhf$1_at_nnrp1.deja.com...
> > In article <394243D8.6F12F9E6_at_swt.edu>,
> > Praveen <praveen_at_swt.edu> wrote:
> > >
> > > --------------0D7A7375526DC6F2967516F0
> > > Content-Type: text/plain; charset=us-ascii
> > > Content-Transfer-Encoding: 7bit
> > >
> > > Hi,
> > >
> > > I have a table "tab" :
> > >
> > > per_no acc_attempt percentage
> > > 1 1 76
> > > 1 2 56
> > > 1 3 85
> > > 2 1 55
> > > 2 2 65
> > > 2 3 75
> > > 3 1 45
> > > 3 2 55
> > > 3 3 65
> > > 3 4 75
> > >
> > > I am trying to write a query that can retrieve the rows which i
have
> > > highlighted and underlined above from the table, that is i want
those
> > > rows to be retrieved from the table where for each 'per_no' the
> > > 'acc_attempt' is maximum.
> > >
> > > Can anybody suggest a way to accomplish this?
> > >
> >
> > yikes -- newsgroups are text, not
html. "underline", "highlighted" --
> > they have no meaning here ;) (that html below is really hard to
read)
> >
> > fortunately you provided enough other info that I think I can
answer....
> >
> > select *
> > from T
> > where acc_attempt = ( select max(acc_attempt)
> > from t t2
> > where t2.per_no = t.per_no )
> > /
> >
> > > Thankyou
> > > Praveen
> > >
> > > --------------0D7A7375526DC6F2967516F0
> > > Content-Type: text/html; charset=us-ascii
> > > Content-Transfer-Encoding: 7bit
> > >
> > > <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
> > > <html>
> > > Hi,
> > > <p>I have a table "tab" :
> > >
> >
<p>per_no &nb
> > sp;
> > > acc_attempt
percentage
> > > <br>
> >
1  
>
> ; &nb
sp
> > ;
> > >
> >
> > [snip]
> >
> > >
> >
> > --
> > Thomas Kyte (tkyte_at_us.oracle.com) Oracle Service Industries
> > Howtos and such: http://osi.oracle.com/~tkyte/index.html
> > Oracle Magazine: http://www.oracle.com/oramag
> > Opinions are mine and do not necessarily reflect those of Oracle
Corp
> >
> >
> > Sent via Deja.com http://www.deja.com/
> > Before you buy.
> >
>
>
-- Thomas Kyte (tkyte_at_us.oracle.com) Oracle Service Industries Howtos and such: http://osi.oracle.com/~tkyte/index.html Oracle Magazine: http://www.oracle.com/oramag Opinions are mine and do not necessarily reflect those of Oracle Corp Sent via Deja.com http://www.deja.com/ Before you buy.Received on Sat Jun 10 2000 - 00:00:00 CDT