About
Pricing
Community
Teams
Start Free Trial
Log in
p-plater
asked on
12/3/2015
Select the Greater of 3 variables and return a different variable SQL 2014
I am Using SQL Server 2014
I have a stored procedure that has 6 parameters.
@OrderID1
@OrderID2
@OrderID3
@OrderValue1
@OrderValue2
@OrderValue3
I need to find the Greatest Order Value and Return the OrderID.
I can select the Max Order Value but I need the OrderID of the Highest Order Value
SELECT MAX(v) FROM (VALUES (@OrderValue1), (@OrderValue2), (@OrderValue3)) AS value(v)
Many Thanks
Microsoft SQL Server 2008
Microsoft SQL Server
2
1
Last Comment
p-plater
8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Ryan Chong
12/3/2015
THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
p-plater
12/3/2015
ASKER
Thanks
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes