Re: SQL Problem

From: damorgan <damorgan_at_exesolutions.com>
Date: Mon, 02 Dec 2002 17:16:19 GMT
Message-ID: <3DEB955A.72D337EA_at_exesolutions.com>


Arun Goel wrote:

> Hi all,
>
> I am facing problem in getting the desired result.
>
> Here is my problem..
> my table look like
> ----->temp(A,B,C);
> Data is as follows:
> A B C
> -- -- --
> A1 B1 C1
> A1 B1 C1
> A1 B1 C1
> A1 B1 C2
> A2 B2 C1
> A2 B2 C1
> A2 B2 C2
>
> For same A,B I need the rows with maximum of same C. & also want to know
> which C.
>
> I am able to find
> A1 B1 3
> A2 B2 3
> using this query.
> select A, B , MAX(Count_C ) as MAXC from
> (
> SELECT Testtable.A, Testtable.B, Count(Testtable.C) AS Count_C
> FROM Testtable
> GROUP BY Testtable.A, Testtable.B , Testtable.C
> ) GROUP BY A, B
>
> But I am mainly interested in what is the corresponding value of C for both
> rows.
> So what I need as result is:
> A1 B1 C1
> A2 B2 C1
>
> Thanks in advance
> --
> ----------------
> Arun Goel
> http://www.crml.uab.edu/~ag

I notice that you are a student so I think it would be inappropriate for someone here to do your homework for you.

There are a number of methods of accompishing what you are trying to do. Start by breaking the problem down. And consider an in-line view.

Daniel Morgan Received on Mon Dec 02 2002 - 18:16:19 CET

Original text of this message