I have a query that works perfectly fine in my test enviroment, but when I try to run it against the production database (exact same data) I get no results, in fact the only way I get results is if I change the date to our production start date of 8/27/12, and that is the only day I can get data from this particular query.
The goal is to get a set of unique rulenumber lines (2 records from each rulenumber that is present in the criteria), doesn't matter if they are random, the goal is to just see any two records for each unique rule number. I had a query before that worked but took wayyy too long to run, I figured this one out and it ran fast, but when I tried in production I came up blank.
SELECT * FROM (SELECT DISTINCT RuleNum FROM Data where ClientID = 'Client1') AS A CROSS APPLY ( SELECT TOP 2 * FROM Data B WHERE B.RuleNum = A.RuleNum ) AS NewTableName where ClientID = 'Client1' and Rundate >= '2012-09-03' and order by NewTableName.RuleNum