Note: The HashValue, LoadDate, and DoNotReport columns were added after the first survey change, so they're selected as NULL for the earliest data.Note: The HashValue, LoadDate, and DoNotReport columns were added after the first survey change, so they're selected as NULL for the earliest data.
I know that the first thing I can do is pull the commented code (as well as all the 0 Neutrals, in the other SELECT statements) because it's not actually necessary to know the number of Neutral responses to calculate the NPS. I was using that previously as I was checking other code to ensure I was getting correct results and for trouble shootingtroubleshooting.
- Is there a better way of doing this than
UNIONing all the individual sub-queries?
- Since it's now going to be in a stored procedure where I can easily write some tSQL around it, would I be better off selecting
Promoters, Detractors and Responses each in their own query then doing the math at the end?
- Would I be best served by having indiciesindices on
CollectionDate, RecommendNPS, DoNotReport, and ClinicID?