What is your SQL Server version? Also, can you post your table structure, some data and desired result based on that data? It will be easier to come up with the solution.
For every expert, there is an equal and opposite expert. - Becker's Law
My blog
My TechNet articles