Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: GROUP BY clause

Re: GROUP BY clause

From: Jan Krueger <jk_at_stud.uni-hannover.de>
Date: Tue, 11 Sep 2007 20:53:36 +0200
Message-ID: <46e6e3a3$0$29377$4c56b896@news-read1.lambdanet.net>


Cristian Cudizio wrote:

> fitzjarrell_at_cox.net wrote:
>> On Sep 9, 12:36 pm, Jan Krueger <j..._at_stud.uni-hannover.de> wrote:

>>> brenda.belt..._at_gmail.com wrote:
>>>> Hi everybody,
>>>> I just got to this area, so hope someone can help me with the
>>>> following issue, I will really appreciate it.
>>>> I want to query a column that is not part of the GROUP BY clause:
>>>> SELECT c.country_id,
>>>> r.region_id,
>>>> r.manag_id,
>>>> SUM(r.sls),
>>>> SUM(r.cst)
>>>> FROM country c INNER JOIN region r ON c.country_key = r.country_key
>>>> GROUP BY c.country_id,
>>>> r.region_id;
>>>> Obviously, it's complaining because r.manag_id is not in the GROUP
>>>> BY clause, but I need the result set to be as defined in the column
>>>> clause. I wonder if there is any way to have these same columns in my
>>>> query keeping my GROUP BY clause as it is now.
>>> Hi Brenda,
>>>
> 
> If adding manag_id to to group clause changes, with what logic you take 
> manag_id?
> if it is indifferent you can use max(r.manag_id).
> Otherwise if it is more complex you can use analytic functions
> 

Thanks Cristian, that's exactly my point. It only changes the resultset if it's indifferent and in that case the suggested inline view showing up the value as suggested some postings before would result in multiple values where only one is allowed.

Jan Received on Tue Sep 11 2007 - 13:53:36 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US