• One way is to save my result in temp table and display it but i know there might be some other better way to perform this..

    Use a reporting tool. This sort of formatting is generally performed by the client application, not the database server.