Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设我有两个数字,@n1,@n2,我想得到更大的一对一的简单表达式,比如 Max(@n1,@n2)。如何编写 T-SQL 的表达式?
DECLARE @n1 INT = 2, @n2 INT = 3 SELECT MAX(n) FROM (VALUES(@n1), (@n2)) t(n)
CASE WHEN @n1 > @n2 THEN @n1 ELSE @n2 END
DECLARE @a int = 45, @b int = 40; SELECT IIF ( @a > @b, @a, @b ) AS Result;