Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Finding Row Wise Max Value From Table
-- Example 1: With Variables DECLARE @Int1 INT = 1, @Int2 INT = 3, @Int3 INT = 5; SELECT MAX(v) FROM (VALUES (@Int1), (@Int2), (@Int3)) AS value(v); -- Example 2: With Static Values SELECT MAX(v) FROM (VALUES (1),(5),(3)) AS value(v); -- Example 3: With Columns CREATE TABLE SampleTable ( ID INT PRIMARY KEY , Int1 INT, Int2 INT, Int3 INT); INSERT INTO SampleTable (ID, Int1, Int2, Int3) VALUES (1, 1, 2, 4); INSERT INTO SampleTable (ID, Int1, Int2, Int3) VALUES (2, 3, 2, 1); INSERT INTO SampleTable (ID, Int1, Int2, Int3) VALUES (3, 1, 3, 2); select * from SampleTable -- Query to select maximum value SELECT ID, (SELECT MAX(v) FROM (VALUES (Int1), (Int2), (Int3)) AS value(v)) AS MaxValue FROM SampleTable;
run
|
edit
|
history
|
help
0
sql server dynamic 12 month time series and pivot with month year column names
Create Tables_2
Mahi
SQL_leetcode
sqript for print !00 numbers with out loop
BRYAN_BD
Mc170404738
stackoverflow_mysql_demo_data
Empresa
megha