I have a table named test with below values. I want to fetch how many users are using open id.
----+----------+-----------+
| NAME | PROVIDER | OPERATION |
+--------+----------+-----------+
| Samuel | Google | P |
| Samuel | Google | V |
| Kannan | Google | V |
| George | Google | V |
| Bush | Google | V |
| Bush | Yahoo | V |
+--------+----------+-----------+
Query: select distinct(Name) from test group by PROVIDER
Result:
+-----------------------+----------+
| count(distinct(NAME)) | PROVIDER |
+-----------------------+----------+
| 4 | Google |
| 1 | Yahoo |
+-----------------------+----------+
In this query I want to ignore the count which a user operation is P for a PROVIDER . How can I do this in a single query?
Output should be
+-----------------------+----------+
| count(distinct(NAME)) | PROVIDER |
+-----------------------+----------+
| 3 | Google |
| 1 | Yahoo |
+-----------------------+----------+
try this,
SQLFiddle Demo