Please ALWAYS include create table statements and all relevant sample data and your expected output from said data. That way we can be sure to write a query that covers all of your needs, and ask intelligent questions if we are uncertain.
Best,
Kevin G. Boles
SQL Server Consultant
SQL MVP 2007-2012
TheSQLGuru on googles mail service