marin-231997 (6/19/2013)
Hello Dixie Flatline and Kingston,many thanks for your quick responses, much appreciated.
Kingston's solution is exactly what I am looking for - I did not know how to group by date within specified date range, but where records do not have a timestamp to group by. Apologies to Dixie Flatline if my request might not have been clear enough, really appreciate your suggestion with CASE for discontinued items.
Kingston's note about non-discontinuation for one instance of item5 is absolutely correct - I overlooked this one when posting the expected results for 01-07-2013 - 03-07-2013.
Many thanks again,
Marin
Glad that I could assist you
Please check the link that I provided about the Tally Tables and if possible read more articles on SSC about Tally tables
I would also like to appreciate the way you posted sample data, DDL and the expected results, great job 🙂
It really helped me in creating the code and testing the solution before posting it here
How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/