Can you please provide some more details like table strucutre and result tant ouput and some dumy data?
_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/