SELECT count(distinct trans_no) from SEARCHES WHERE comp_id=675 and result='o';

----- Original Message ----- From: "Richard Reina" <[email protected]>
To: <[email protected]>
Cc: <[email protected]>
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/[email protected]



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[email protected]

Reply via email to