我是 SQL 新手,如果条件为真,我想执行一条语句,如果条件为假,则执行另一条语句。
SQL Server 2012 查询
select
if s.SpecialInsttPlan = 'No'
BEGIN
(s.TotalBill - s.Advance) / s.Installments as Installment
else
'Special' as Installment
END
from
SalesInvoice s
left join
InstallmentPaymentHistory iph
on iph.SalesInvoiceID = s.SalesInvoiceID
where
iph.SalesInvoiceID = 41
group by
s.TotalBill,
s.Advance,
s.Installments
我的查询以以下错误结束
Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'if'.
Msg 102, Level 15, State 1, Line 4
Incorrect syntax near 's'.
请帮忙解决