mardi 22 mai 2018

sql if statement not working

I can't get this if statement to work. I'm trying to say 'if(number of dates) is greater than 330, return 'x', otherwise give me the (number of dates)

SELECT     if(ROUND(COUNT(ClosedDate) / 10, 0) * 10 > 330 then 'X' else ROUND(COUNT(ClosedDate) / 10, 0) * 10) end AS [Previous Day Sales]
FROM         PartsSales
WHERE     (MONTH(ClosedDate) = MONTH(GETDATE())) AND (YEAR(ClosedDate) = YEAR(GETDATE())) AND (DAY(ClosedDate) = DAY(GETDATE() - 13))

Aucun commentaire:

Enregistrer un commentaire