Sql 否则,如果在我的select语句中

Sql 否则,如果在我的select语句中,sql,sql-server,Sql,Sql Server,我希望在select语句中有一个else if,我已经尝试使用case when,但结果不太准确 这是我的一段脚本 select distinct t.MovementDate, t.ContractMovementID, t.GID,t.ReferenceGID, p.refno, t.amount,convert(date,t.CreatedDate) as createdDat from LIF_MGM_T_Contract p inne

我希望在select语句中有一个else if,我已经尝试使用case when,但结果不太准确

这是我的一段脚本

select distinct t.MovementDate, t.ContractMovementID, t.GID,t.ReferenceGID, 
                p.refno, t.amount,convert(date,t.CreatedDate) as createdDat
from 
    LIF_MGM_T_Contract p
    inner join LIF_MMS_T_PolicySuspense s with (nolock) 
        on s.ContractGID = p.GID
    inner join LIF_TMS_T_FinancialTransaction t with (nolock) 
        on t.ContractGID = p.GID
where  
    p.refno = '1030642 - 1 - Mohahlaula' 
    and t.ReversedIndicator = 1
    and t.counter = (select min(counter) 
                     from LIF_TMS_T_FinancialTransaction t2 with (nolock) 
                     where t2.ContractGID = p.GID 
                           and t2.ReversedIndicator = 1 
                           and t2.MovementDate = t.MovementDate )

因此,如果t2.reversedindicator=0和date=getdate()返回结果,我需要一个else。。希望这是有意义的

您是否尝试过使用
运算符?@a_horse_,没有名字--Microsoft SQLServer@Enfyve我有,但它只看了第一个是“反向指示符”,您如何使用OR运算符来处理这个问题?使用括号来封装您的条件。