0

Slightly complicated question.

I have table below:

UserID | Date       |
---------------------
1      | 2015/01/01 |
1      | 2015/01/02 |
1      | 2015/01/03 |
1      | 2015/01/04 |
2      | 2015/01/01 |
2      | 2015/01/02 |
3      | 2015/01/01 |
3      | 2015/01/02 |
3      | 2015/01/03 |
4      | 2015/01/01 |
4      | 2015/01/02 |
4      | 2015/01/03 |
4      | 2015/01/04 |

I would like to count all duplicates and then update DupOrder column with numbers representing each duplicated UserID in the same order as date (I hope this make sense).

Here is what I would like to end up with:

DupOrder | UserID | Date       |
--------------------------------
1        | 1      | 2015/01/01 |
2        | 1      | 2015/01/02 |
3        | 1      | 2015/01/03 |
4        | 1      | 2015/01/04 |
1        | 2      | 2015/01/01 |
2        | 2      | 2015/01/02 |
1        | 3      | 2015/01/01 |
2        | 3      | 2015/01/02 |
3        | 3      | 2015/01/03 |
1        | 4      | 2015/01/01 |
2        | 4      | 2015/01/02 |
3        | 4      | 2015/01/03 |
4        | 4      | 2015/01/04 |

I use mysql.

Chriser
  • 157
  • 1
  • 4
  • 12

0 Answers0