任何人都可以請更正我嵌套的Select Case When的語法。嵌套Select Case的語法錯誤
Update [Tab-2 sourcing]
set POQty = a.Quantity
from
(
select
case when D.POQty > [Tab-2 sourcing].OpenQuantity
then D.POQty
case when D.POQty < [Tab-2 sourcing].OpenQuantity
then
(
case when D.POQty > [Tab-2 sourcing].AlreadyAlloted
then D.POQty
)
as Quantity
from DemandPortal D
inner join [Tab-2 sourcing]
on
D.PONumber = [Tab-2 sourcing].PONumber
)a
我是新來的sql server,所以不知道如何編寫正確的選擇大小寫。
請解釋所需的邏輯。從顯然不工作的邏輯推斷正確的邏輯並不容易! –
'...時......時......時......然後......其他......結束......「的情況。 'else'部分是可選的。 – jarlh
「End」關鍵字丟失 – Anagha