限制检索过去的年份值 [英] restrict the past yeared values to retrive
本文介绍了限制检索过去的年份值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
hi ,,
对于我的应用程序
我还想在Valid_From_Date之前检查计划,并且还限制是否要检索日期是否在Valid_To_Date到期之后..
,
for my application
i want to check the scheme before the Valid_From_Date also and also to restrict to retrive if the date is after the expiration of Valid_To_Date..
select (case when Deposit_Type =1 then 'RD' else 'FD' end) as Deposit_Type,
ID,
Scheme_Name,
(case when Mode_Operation=1 then 'General' else 'SC' end)as Mode_Operation,
Period_Type,
Period_Value,
Type_Interest,
Interest_Rate,
LockIn_Period,
PNL_Interest,
Is_Active from Scheme WHERE GETDATE() BETWEEN Valid_From_Date AND Valid_To_Date
推荐答案
我想我明白你的意思了.您想要当前记录之前的记录吗?
如果查询实际上返回了某些内容,则可以执行以下操作:
I think I understand what you''re after. You want the record(s) previous to the current record?
If your query actually returns something, you could do this:
select (case when Deposit_Type =1 then 'RD' else 'FD' end) as Deposit_Type,
ID,
Scheme_Name,
(case when Mode_Operation=1 then 'General' else 'SC' end)as Mode_Operation,
Period_Type,
Period_Value,
Type_Interest,
Interest_Rate,
LockIn_Period,
PNL_Interest,
Is_Active from [Scheme]
WHERE GETDATE() NOT BETWEEN Valid_From_Date AND Valid_To_Date
如果您只想要最新的先前记录:
And if you want just the most current previous record:
select TOP 1
(case when Deposit_Type =1 then 'RD' else 'FD' end) as Deposit_Type,
ID,
Scheme_Name,
(case when Mode_Operation=1 then 'General' else 'SC' end)as Mode_Operation,
Period_Type,
Period_Value,
Type_Interest,
Interest_Rate,
LockIn_Period,
PNL_Interest,
Is_Active from [Scheme]
WHERE GETDATE() NOT BETWEEN Valid_From_Date AND Valid_To_Date
ORDER BY Valid_From_Date DESC
select (case when Deposit_Type =1 then 'RD' else 'FD' end) as Deposit_Type,
ID,
Scheme_Name,
(case when Mode_Operation=1 then 'General' else 'SC' end)as Mode_Operation,
Period_Type,
Period_Value,
Type_Interest,
Interest_Rate,
LockIn_Period,
PNL_Interest,
Is_Active from Scheme WHERE GETDATE() < Valid_To_Date
您想获取所有记录,而与有效开始日期无关,但唯一的条件是该记录应自当前日期起有效
You want to fetch all records irrespective of validstartdate but the only condition is it should be valid as of current date
这篇关于限制检索过去的年份值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文