I have a data table like the name as data_table
and sample data are like below
id | name | type | temp_id |
---|---|---|---|
1 | n1 | t1 | |
1 | n1 | t1 | |
1 | n1 | t1 | |
1 | n1 | t1 | |
2 | n1 | t1 | |
2 | n1 | t1 | |
2 | n1 | t1 | |
2 | n1 | t1 | |
2 | n1 | t1 |
I would like to update
, temp_id
columns with specific unique values. Like below.
id | name | type | temp_id |
---|---|---|---|
1 | n1 | t1 | 1001 |
1 | n1 | t1 | 1002 |
1 | n1 | t1 | 1003 |
1 | n1 | t1 | 1004 |
2 | n1 | t1 | 1005 |
2 | n1 | t1 | 1006 |
2 | n1 | t1 | 1007 |
2 | n1 | t1 | 1008 |
2 | n1 | t1 | 1009 |
2
Answers
Using CASE Expression:
You can use a CASE expression to set different values for each row you want to update. Here’s an example:
fiddle