Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Simple SQL (or complex???)
On Mar 19, 10:37 pm, DA Morgan <damor..._at_psoug.org> wrote:
> P_swigg..._at_yahoo.com wrote:
> > I'm looking for some help on SQL.
>
> > very simple table:
>
> > SQL> select * from patt;
>
> > CMB COD
> > ---------- --------
> > 1 A
> > 1 B
> > 1 C
> > 2 X
> > 2 B
> > 2 C
> > 3 A
> > 3 B
> > 3 C
>
> > As I can see there are :
> > 2 sets of same COD: A,B,C (for CMB 1 & 3) with max(CMB)=3
> > 1 set of same COD: X,B,C (for CMB 2) with max(CMB)=2
>
> > However, I cannot get my query to get result:
> > max(CMB) count(*)
> > 3 2
> > 2 1
>
> > Hallelujah Hollywood for who can give me the sql...:-))
>
> Post your query. This looks a lot like homework so it would
> be helpful to see what you did.
> --
> Daniel A. Morgan
> University of Washington
> damor..._at_x.washington.edu
> (replace x with u to respond)
> Puget Sound Oracle Users Groupwww.psoug.org- Hide quoted text -
>
> - Show quoted text -
Well, I'm from 1969 and I'm working for 10 years as developer but now indeed I start almost crying like a little schoolboy... I started already 20 times on this query. Tried several times something like this:
select max(p.cmb), count(*)
from patt p,
(select cmb, cod from patt) x
from patt where p.cod=x.cod)
MAX(P.CMB) COUNT(*)
---------- ----------
1 3 2 3 3 3Received on Mon Mar 19 2007 - 17:54:32 CDT
![]() |
![]() |