Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Demo
CREATE TABLE #Table1 (datekey int, pointkey int, filter_key varchar(4), t_key int) ; INSERT INTO #Table1 (datekey,pointkey, filter_key, t_key) VALUES (5506061, 37, NULL, 1), (5506061, 37, NULL, 1), (5506061, 37, NULL, 1), (5506061, 37, NULL, 1), (5506061, 37, NULL, 1), (5506061, 37, NULL, 1), (5506763, 37, NULL, 2), (5506763, 37, NULL, 2), (5506763, 37, NULL, 2) ; ;with cte as ( SELECT datekey, pointkey, filter_key, CASE WHEN t_key = 1 AND Row_number()OVER(ORDER BY datekey,pointkey) = 1 THEN 1 ELSE 2 END AS new_filter_key, t_key FROM #Table1 ) update cte set filter_key = new_filter_key select * from #table1
run
|
edit
|
history
|
help
0
QLDT_TUAN 7
Insert multiple parent-child records
Lunes
robot-grading
Empresa
TUAN 7_QUAN LY DE TAI
Libros
add loopback linked server
Creating tables in sql server
1