gpt4 book ai didi

sql - SQL Case 语句中的运算优先顺序是什么?

转载 作者:行者123 更新时间:2023-12-03 02:20:04 24 4
gpt4 key购买 nike

我正在花时间探索如何最好地编写以下内容:

SET @SAMPLE = (SELECT CASE
WHEN @A < 0.01 AND @B < 0.01 THEN -1
WHEN @A < 0.01 THEN @B
ELSE @C
END )

我在这里没有得到我所期望的。运行此命令后,我发现 @SAMPLE 包含 0.00。感谢您的指导。

最佳答案

The CASE statement evaluates its conditions sequentially and stops with the first condition whose condition is satisfied

从你的例子中,我们只能推断出 @B 或 @c 为零。

操作优先级通常是指首先计算哪个运算符(例如“*”或“-”)。您的问题可能应该标题为“案例评估顺序”。

http://technet.microsoft.com/en-us/library/ms181765.aspx

关于sql - SQL Case 语句中的运算优先顺序是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19141634/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com