Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Max from multiple columns
create table test(id int, col1 int, col2 int, col3 int) insert into test values(10, 24,45, 32) select * from test t1 cross apply( select max(col1) max_value from (select col1 union select col2 union select col3) t1) t2 select id, max(case oper when 1 then col1 when 2 then col2 when 3 then col3 end) max_value from test t1 cross join (values (1),(2),(3)) t2(oper) group by id
run
|
edit
|
history
|
help
0
NAMES
New_1
manish
SQL_DS_collections
TSQL - Globally unique string generator
aaa
deepu
service_delivery_task
SQL ASSESSMENT
Rno 37 boat 2