April 21, 2013 at 6:18 pm
Hi Guys need some help with converting this part of a query from MySQL, I need to run this on MSSQL.
Select (SUM(if(rating = 5, 1, 0))-SUM(if(RATING < 4, 1, 0)))/SUM(if(RATING > 0, 1, 0))*100 as RECENT_NPS,
SUM(if(RATING > 0, 1, 0)) as RECENT_RATINGS,
............
April 21, 2013 at 8:50 pm
Hi
Try replacing your IF functions with a CASE statements, eg
if(rating = 5, 1, 0)
becomes
CASE WHEN rating = 5 THEN 1 ELSE 0 END
In SQL 2012 there is also the IIF function that could be used
April 21, 2013 at 10:44 pm
perfect thanks MickyT
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy