Я пытаюсь создать оператор case, чтобы показать только значение AmountRequested
на основе значения в MortgageStatus
В основном, если MortgageStatus
= 4 или 5 или 6 или 7, тогда я хочу увидеть значение AmountRequested
покажи мне 0
SELECT s.ISDESC as Source,
p.ClientId,p.Id AS [Profile ID],c.CaseTypeDesc As [Case Type],u.FullName AS Advisor,
ISNULL(app.StatusDesc, ' No contact') as [Mortgage status] ,
CASE pm.AmountRequested
WHEN pm.MortgageStatus IN (4,5,6,7) THEN pm.AmountRequested
Else '0'
END,
em.Description,
pm.ProcFeeExp,
pm.ArrangementFee,t.DueDate as [Enquiry Date],s.ISDESC
From Tasks AS t
LEFT JOIN dbo.tbl_Profile AS p
ON t.FK_ProfileId = p.ID
LEFT JOIN dbo.tbl_CaseTypes AS c
ON c.CaseTypeID = p.CaseTypeID
LEFT JOIN dbo.tbl_User AS u
ON u.UserId = t.takenBy
LEFT JOIN tbl_Profile_Mortgage AS pm
ON p.Id = pm.FK_ProfileId
LEFT JOIN tbl_AppStatus AS app
ON pm.MortgageStatus = app.StatusId
LEFT JOIN tbl_DDEnquiryMethod AS em
ON t.EnquiryMethod = em.id
LEFT JOIN dbo.tbl_EnquiryType AS e
ON t.EnquiryType = e.EnquirytypeId
LEFT JOIN tbl_DDInitialSource as s
On t.EnquirySource = s.ISID
Спасибо