SQL 根据参数从 table 中排除行

SQL exclude rows from table based on parameter

我有一个 table 数据,想根据以下参数创建一个案例:

DECLARE @FY_Ending INT
SET @FY_Ending = 2020

如果 @FY_Ending < 到 2020 年,则取名为 Code

的列

如果 @FY_Ending 是 >= 2020,则取列名代码,但将 LA_Code 放在 (810,811)

(注:代码只是一列不同的数字,2020年以后想排除)

我将如何写这篇文章?

提前致谢

select code
from your_table
where (@FY_Ending < 2020 and LA_Code in (810,811))
   or @FY_Ending >= 2020 

sql 应该是这样的

select Code from Table where (@FY_Ending < 2020) or (@FY_Ending >= 2020 and LA_Code in (810,811)