last day (15 days later) » 

11:15
Anyone can help please to get the expected results?
Expected results:
+-----+-----+
| Val | Seq |
+-----+-----+
|   2 |   0 |
|   2 |   0 |
|   1 |   1 |
|   1 |   2 |
|   1 |   3 |
|   2 |   0 |
|   1 |   1 |
|   2 |   0 |
|   1 |   1 |
|   1 |   2 |
+-----+-----+
Note: There is no other columns in the table T except Val column
@Sami do you need a rank for each value?
@Sami Is there a reason you chose to ask in chat rather than on the main site?
@McNets Nope, It's a seq, if val = 2 then 0, else start the seq again from 1
@PaulWhite There is no reason, expect I believe I'll get answers here too (quick one) and it's just for learning, no matter if I got answers or not
@Sami How do you set the ORDER?
@McNets As you can see there is no order there and there is no column to determine the order
Thnx @PaulWhite
11:22
11 messages moved from The Heap™ – Consultancy ©®
@McNets I have moved Sami's question here.
@Sami No order, no possible rank or other window function
It seems there is no solution, even if we add an identity column to the T table
Thanks for you both @PaulWhite & @McNets
No worries.
If you add an identity column: dbfiddle.uk/…
@McNets Nope, that won't reset the Seq, see the expected results ^
11:32
Yes, it requires more job setting groups before to rank
but it's possible
give me some time
Until now, I can't came up with a solution. Thanks for pointing, I'll work more to learn more.
Have a look ^^^
Maybe another user is able to get a better solution
11:51
Great @McNets that's awesome. Thank you so much for your time & effort.
Think that posting your question in main site you could help other ppl
12:12
I think I'll suggest that more strongly next time.

last day (15 days later) »