Find 40 Problems in This Stored Procedure.


Aaron Bertrand posted a challenge:

We’re going to use the AdventureWorks sample database (get your copy here), where the folks in marketing requested a list of users to e-mail a new promotional campaign. The customers need to meet at least one of the following criteria:

last placed an order more than a year ago placed 3 or more orders in the past year have ordered from a specific category in the past two weeks

These criteria don’t have to make sense! They just need to make the query a little bit more complex than your average CRUD operations.