lundi 10 août 2015

SQL query for finding records

I have a table named PAYMENT. Within this table I have a user ID, an account number, a ZIP code and a date. I would like to find all records for all users who have active and deactive then active again as Count.

This is how the table looks like:

| user_id | account_no | zip   |      date | register  |
|       1 |        123 | 55555 | 12-DEC-09 | active    |
|       1 |        123 | 55555 | 13-DEC-09 | disactive |
|       1 |        123 | 55555 | 14-DEC-09 | active    |
|       2 |        456 | 55555 | 14-DEC-09 | disactive |
|       3 |        789 | 55555 | 14-DEC-09 | disactive |
|       4 |        999 | 55555 | 14-DEC-09 | active    |

The result should look similar to this:

I use COUNT(user_id) so the result will only come our as

= 1

i dont know is this possible?

Aucun commentaire:

Enregistrer un commentaire