I would like to have this +3 apply when the paymentterm if is less than 45.
So the current code is using case statement.
SELECT
SUM(sblPOAmount) AS totalPOAmt,
case
when paymentTerm = '45 Days'
then DATENAME(Day, DATEADD(day, SUBSTRING(paymentTerm, 1, 2) + 3, SBLInvoiceDate))
else DATENAME(Day, DATEADD(day, SUBSTRING(paymentTerm, 1, 2) + 0, SBLInvoiceDate))
end
FROM
[A_Sys].[dbo].[Eventtbl]
WHERE DATENAME(MONTH, DATEADD(day,SUBSTRING(paymentTerm, 1, 2)+3,SBLInvoiceDate))='June'
AND DATENAME(YEAR, DATEADD(day,SUBSTRING(paymentTerm, 1, 2)+3,SBLInvoiceDate))='2017'
Group By paymentTerm,SBLInvoiceDate
The Sum having multiple result due to "Group By", but if i run it without Group By , it will have error message.
Please help