I am looking at a lengthy query that needs refactoring and clean up. The overall jist of the query is this:
We have a customer with several items they have subscribed to.
We have a lookup table for these subscriptions with the number of days the subscription is good for.
We have another table that has a count of the days since the subscription began.
We basically then do a join and a big case (I mean really big) case statement with different logic for each subscription code that matches what the customer has subscribed to. In the end the sp returns the subscription code and a Y or N flag for if
the subscription has expired.
I've looked at PIVOT and I can't see how it would help here. ROW_NUMBER isn't much use as there really aren't any sub queries. I'm racking my brain trying to figure out a way to simplify this monsterous case statement and coming up empty so I was hoping
for some ideas from others. Redesign of tables and approach is an option as we are already moving alot of hard coding to table driven etc.
Thank You for your help and ideas.
View Complete Post