Please attach a screenshot of sample data or post query which you wrote so that we can do modification in that and give you desired result,
_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/