It is possible to record a data that have a straight row in mysql based on date or sequence?
Posted
by
user1987816
on Stack Overflow
See other posts from Stack Overflow
or by user1987816
Published on 2014-08-25T04:18:20Z
Indexed on
2014/08/25
4:19 UTC
Read the original article
Hit count: 314
I want to get the data that have a straight Sell more than 3 times, it is possible in mysql? If not, how to get it right? I'm need it on mysql or php.
my database:-
+----------+---------------------+--------+
| Username | Date | Action |
+----------+---------------------+--------+
| Adam | 2014-08-20 22:30:20 | Sell |
| Adam | 2014-08-20 22:30:20 | Sell |
| Adam | 2014-08-20 22:30:20 | Sell |
| Adam | 2014-08-20 22:30:20 | Buy |
| Adam | 2014-08-20 22:30:20 | Buy |
| Adam | 2014-08-20 22:30:20 | Sell |
| Adam | 2014-08-20 22:30:20 | Sell |
| Adam | 2014-08-20 22:30:20 | Sell |
| Adam | 2014-08-20 22:30:20 | Sell |
| Nick | 2014-08-20 22:30:20 | Sell |
| Nick | 2014-08-20 22:30:20 | Sell |
| Nick | 2014-08-20 22:30:20 | Sell |
| Nick | 2014-08-20 22:30:20 | Sell |
| Nick | 2014-08-20 22:30:20 | Buy |
+----------+---------------------+--------+
From the table above, I need to list out all data that have a straight sell more then 3 times.
RESULT
+----------+---------------------+--------+-------------+
| Username | Date | Action | Straight 3+ |
+----------+---------------------+--------+-------------+
| Adam | 2014-08-20 22:30:20 | Sell | 3 |
| Adam | 2014-08-20 22:30:20 | Sell | 4 |
| Nick | 2014-08-20 22:30:20 | Sell | 4 |
+----------+---------------------+--------+-------------+
© Stack Overflow or respective owner