List:General Discussion« Previous MessageNext Message »
From:Mike Blezien Date:May 16 2006 6:39pm
Subject:Re: Baffled by error
View as plain text  
Peter,
----- Original Message ----- 
From: "Peter Brawley" <peter.brawley@stripped>
To: "Mike Blezien" <mickalo@stripped>
Cc: "MySQL List" <mysql@stripped>
Sent: Tuesday, May 16, 2006 1:25 PM
Subject: Re: Baffled by error


> Mike,
> 
> >How would this query be constructed with the HAVING clause,
> >not real fimilar with this type of clause.
> 
> SELECT
>  a.id,
>  a.name,
>  a.company,
>  SUM(c.agent_product_time) AS mins
> FROM account a
> LEFT JOIN calls c ON c.account_id = a.id
> WHERE c.calldate >= DATE_SUB(NOW(),INTERVAL 14 DAY)
>  AND c.agent_id = 9
> GROUP BY a.account_id
> HAVING SUM(c.agent_product_time) >= 500
> ORDER BY mins;
> 
> PB

Much appreciated and it works prefectly now... :)

Thx's

Mike

> -----
> 
> Mike Blezien wrote:
>> Peter,
>> ----- Original Message ----- From: "Peter Brawley" 
>> <peter.brawley@stripped>
>> To: "Mike Blezien" <mickalo@stripped>
>> Cc: "MySQL List" <mysql@stripped>
>> Sent: Tuesday, May 16, 2006 1:07 PM
>> Subject: Re: Baffled by error
>>
>>
>>> Mike Blezien wrote:
>>>> Hello,
>>>>
>>>> MySQL 4.1.12
>>>>
>>>> trying to figure out why I keep getting this error with the 
>>>> following query:
>>>>
>>>> SELECT c.account_id,a.name,a.company,SUM(c.agent_product_time) AS 
>>>> mins FROM account a LEFT JOIN calls c ON c.account_id = a.id WHERE 
>>>> c.calldate >= DATE_SUB(NOW(),INTERVAL 14 DAY) AND c.agent_id = 9
>>>> AND SUM(c.agent_product_time) >= '500' GROUP BY a.account_id
>>>> ORDER BY mins
>>> WHERE doesn't understand aggregation. Move the condition 
>>> SUM(c.agent_product_time) >= 500 to a HAVING clause.
>>>
>>> pb
>>
>> How would this query be constructed with the HAVING clause, not real 
>> fimilar with this type of clause.
>>
>> thx's
>> Mike

Thread
Baffled by errorMike Blezien16 May
  • Re: Baffled by errorRhino16 May
  • Re: Baffled by errorChris Sansom16 May
  • RE: Baffled by errorIng. Edwin Cruz16 May
    • Re: Baffled by errorMike Blezien16 May
  • Re: Baffled by errorMike Blezien16 May
  • Re: Baffled by errorPeter Brawley16 May
  • Re: Baffled by errorRhino16 May
  • Re: Baffled by errorMike Blezien16 May
    • Re: Baffled by errorPeter Brawley16 May
  • Re: Baffled by errorMike Blezien16 May
  • RE: Baffled by errorGordon16 May
    • Re: Baffled by errorMike Blezien16 May