I have a table layed out this way:
id username value week
4 john 4 1
5 john 4 1
2 john 4 1
1 john 4 1
3 john 4 1
1 jay 4 1
3 jay 4 1
2 jay 4 1
5 jay 4 1
4 jay 4 1
Is their a way to update the first 3 records for each group (username) setting the value to a random 1 or 0 in the order I have above (I am sorting by newid() so the ids are random like you see above.
the result for above would look like this:
id username value week
4 john 1 1
5 john 1 1
2 john 0 1
1 john 4 1
3 john 4 1
1 jay 0 1
3 jay 1 1
2 jay 0 1
5 jay 4 1
4 jay 4 1
id username value week
4 john 4 1
5 john 4 1
2 john 4 1
1 john 4 1
3 john 4 1
1 jay 4 1
3 jay 4 1
2 jay 4 1
5 jay 4 1
4 jay 4 1
Is their a way to update the first 3 records for each group (username) setting the value to a random 1 or 0 in the order I have above (I am sorting by newid() so the ids are random like you see above.
the result for above would look like this:
id username value week
4 john 1 1
5 john 1 1
2 john 0 1
1 john 4 1
3 john 4 1
1 jay 0 1
3 jay 1 1
2 jay 0 1
5 jay 4 1
4 jay 4 1