我不确定如何对此进行编码。下面是我在IF语句中需要的场景。这应该被分成两个不同的IF语句,或者我可以使用CASE吗?我是编程新手,所以任何帮助都将不胜感激。
Scenerios:如果selling_flag = 'N‘和calculation_flag = 'Y’,则返回list_price。如果selling_flag = 'Y‘和calculation_flag = 'Y’,则返回customer_price。如果calculation_flag = 'N‘,则返回unit_selling
目前我有:
IF selling_flag = 'N' AND calculation_flag = 'Y' THEN
return list_price;
ELSE
return customer_price;
END IF;
IF calculation_flag = 'N' THEN
return selling_price;
END IF;
END;谢谢。
发布于 2016-05-10 02:07:28
您可能会这样做,Case Statements PLSQL
CASE
WHEN selling_flag = 'N' AND calculation_flag = 'Y' THEN list_price;
WHEN selling_flag = 'Y' AND calculation_flag = 'Y' THEN customer_price;
ELSE selling_price;
END CASE;其中有两个条件,如果都不满足,则缺省为selling_price。
发布于 2016-05-10 02:07:56
如果这是PL/SQL代码,则通常使用elsif
IF selling_flag = 'N' AND calculation_flag = 'Y' THEN
return list_price;
ELSIF selling_flag = 'Y' AND calculation_flag = 'Y'
return customer_price;
ELSIF calculation_flag = 'N' THEN
return selling_price;
END IF; 这也可以写成:
IF calculation_flag = 'Y' THEN
IF selling_flag = 'N' THEN
return list_price;
ELSE
return customer_price;
END IF;
ELSE
return selling_price;
END IF; https://stackoverflow.com/questions/37122469
复制相似问题