List:General Discussion« Previous MessageNext Message »
From:DaWiz Date:December 13 2009 7:22pm
Subject:Re: Query help
View as plain text  
SELECT count(distinct trans_no) from SEARCHES WHERE comp_id=675 and 
result='o';

----- Original Message ----- 
From: "Richard Reina" <richard@stripped>
To: <mysql@stripped>
Cc: <richard@stripped>
Sent: Sunday, December 13, 2009 11:36 AM
Subject: Query help


>I was wondering if someone could lend a hand with the following query.  I 
>have table.
>
> SEARCHES
> |ID |trans_no|comp_id|result
> 13  | 455    |  675    | o
> 15  | 302    |  675    | o
> 16  | 455    |  675    | o
> 12  | 225    |  629    | y
>
> SELECT count(*) FROM SEARCHES WHERE comp_id=675 AND result='o' GROUP BY 
> trans_no;
>
> gives me a count of 3.
>
> However, what I need is a count for how many different (unique) 
> transactions company number 675 got a result 'o' which would be 2 (455 & 
> 302).  I have tried different group by columns but to no avail. Can 
> someone help?
>
> Thanks,
>
> Richard
>
> -- 
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/mysql?unsub=1
> 

Thread
Query helpRichard Reina13 Dec
  • RE: Query helpJason Trebilcock13 Dec
  • Re: Query helpColin Streicher13 Dec
  • Re: Query helpDaWiz13 Dec