Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Demo
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
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 t_key) = 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
View schema
Execution time: 0,02 sec, rows selected: 9, rows affected: 18, absolute service time: 0,16 sec
edit mode
|
history
|
discussion
datekey
pointkey
filter_key
t_key
1
5506061
37
1
1
2
5506061
37
2
1
3
5506061
37
2
1
4
5506061
37
2
1
5
5506061
37
2
1
6
5506061
37
2
1
7
5506763
37
2
2
8
5506763
37
2
2
9
5506763
37
2
2