I have this table in mysql:
name ID
B1 1
B2 1
B3 1
B4 2
B5 2
B6 2
A1 3
A2 3
A3 3
I’d like to add data into a column, notifying that the id will change at the next line. Something like this:
name beforeChange ID
B1 NO 1
B2 NO 1
B3 YES 1
B4 NO 2
B5 NO 2
B6 YES 2
A1 NO 3
A2 NO 3
A3 NO 3
A4 NO 3
Is there any way to do this in sql?
Thanks!
Ugly as sin & probably far from ideal from an efficiency point of view but seems to work: