Ok the ideas are here and if you want to clearly solution you must post the table definition and some sample data just to do the things correct!
============================================================
SELECT YOUR PROBLEM FROM SSC.com WHERE PROBLEM DESCRIPTION =
http://www.sqlservercentral.com/articles/Best+Practices/61537/[/url]