I need to make a if-else statement in the query meaning I only want to add the OpenAmount to ExpectedAmount if the type = Cash, the problem is that it only gives me the cash row not the other row.
Dim TenderList = (From t In EnData.BatchRecs
Join b In EnData.RegShifts
On t.BatchID Equals b.RegShiftID
Where t.BatchID = ID
Let ExpectedAmount = (t.ExpectedAmount + b.OpeningAmo开发者_JAVA技巧unt)
Where t.TenderName = "CASH"
Select t.BatchRecID, ExpectedAmount, t.ExpectedCount,
t.PickUpAmount, t.TenderName, OverShort,
t.PickUpCount, t.TenderID)
Can this be done?
You should be able to use a conditional statement.
Let ExpectedAmount = If(t.TenderName = "CASH",
t.ExpectedAmount + b.OpeningAmount,
t.ExpectedAmount)
You also don't need Where t.TenderName = "CASH"
if you do this.
精彩评论