Re: What is wrong with this query?

From: No Name <louisparsonsusa_at_netscape.net>
Date: Tue, 12 Feb 2002 19:33:32 GMT
Message-ID: <3C69619E.90109_at_netscape.net>


ORA-00937 not a single-group group function Cause: A SELECT list cannot include both a group function, such as AVG, COUNT, MAX, MIN, SUM, STDDEV, or VARIANCE, and an individual column expression, unless the individual column expression is included in a GROUP BY clause.
Action: Drop either the group function or the individual column expression from the SELECT list or add a GROUP BY clause that includes all individual column expressions listed.

MarkyG wrote:

> Try
> 
> SELECT distinct owner_id ||'  ' as "Owner ID", Count(distinct owner_id) as
> "Purch. Count", Sum(price) as "Purch. Count",
>        avg(price) as "Avg. Purch."
> FROM   purchase_tbl
> WHERE  purchase_date BETWEEN
>        TO_DATE('01-01-1998', 'mm-dd-yyyy') and
>        TO_DATE('12-31-2000', 'mm-dd-yyyy') 
> GROUP BY
>        owner_id;
> 
> m
> 
> sergiugp_at_aol.com (Sergiu gp) wrote in message news:<20020212060201.10819.00001049_at_mb-ba.aol.com>...
> 

>>Guys,
>>
>>I wonder why am I getting a not a single-group group function error with this
>>query:
>>
>>SELECT distinct owner_id ||' ' as "Owner ID", Count(distinct owner_id) as
>>"Purch. Count", Sum(price) as "Purch. Count",
>> avg(price) as "Avg. Purch."
>>FROM purchase_tbl
>>WHERE purchase_date BETWEEN
>> TO_DATE('01-01-1998', 'mm-dd-yyyy') and
>> TO_DATE('12-31-2000', 'mm-dd-yyyy')
>>
>>Do I have to use a nested query, and if yes, which column should I use for the
>>inner query?
>>
Received on Tue Feb 12 2002 - 20:33:32 CET

Original text of this message