List:General Discussion« Previous MessageNext Message »
From:Mário Gamito Date:January 21 2008 10:53am
Subject:Re: Newbie: A single number
View as plain text  
Hi Michael,

I've tried your tip, but I get the error:

"#1054 - Unknown column 'ct_ct_comment_agent' in 'field list'"

Any ideas ?

Warm Regards,
Mário Gamito

Michael Cole wrote:
> You have two rows the zero which has a single row and the other row
> 
> If the answer you are after is 48.
> 
> select sum(ct_ct_comment_agent) from (SELECT comment_approved, 
> COUNT(comment_agent) as ct_comment_agent from wp_comments WHERE
>  comment_agent LIKE '%Linux%' OR comment_approved=0 GROUP by
> comment_approved )as a
> 
> 
> On Monday 21 January 2008 6:07:46 pm Mário Gamito wrote:
>> Hi,
>>
>> I'm trying to get a single number out of a SELECT statement:
>>
>> SELECT comment_approved, COUNT(comment_agent) from wp_comments WHERE
>> comment_agent LIKE '%Linux%' OR comment_approved=0 GROUP by
>> comment_approved
>>
>> But instead i get two rows:
>> |------------------------------------------
>> |comment_approved | COUNT (comment_agent) |
>> |------------------------------------------
>> |0                |                     1 |
>> |------------------------------------------
>> |1                |                    47 |
>> |-----------------------------------------|
>>
>> I've Google about it but found no answer (my bad, probably).
>>
>> What I want is to have just 47 as a result of the SELECT.
>>
>> Any help would be appreciated.
>>
>> Warm regards,
>> Mário Gamito
> 
> 
> 

Thread
Newbie: A single numberMário Gamito21 Jan
  • Re: Newbie: A single numberSebastian Mendel21 Jan
    • Re: Newbie: A single numberMário Gamito21 Jan
      • Re: Newbie: A single numberJoerg Bruehe23 Jan
  • Re: Newbie: A single numberMichael Cole21 Jan
    • Re: Newbie: A single numberMário Gamito21 Jan
  • Re: Newbie: A single numberAndy Wallace21 Jan