Please start any new threads on our new 
    site at https://forums.sqlteam.com.  We've got lots of great SQL Server
    experts to answer whatever question you can come up with.
    
        | 
                
                    | 
                            
                                | Author | Topic |  
                                    | sreeramStarting Member
 
 
                                        1 Post | 
                                            
                                            |  Posted - 2013-08-13 : 05:32:32 
 |  
                                            | Hi,I have written the below queryselect type_payment,booked_by,sum(grand_total) GrandTotal from jp_lr group by type_payment,booked_by order by type_payment;The output looks like the below.Type_Payment Booked_by  Grand_total====================================ON A/C	     JPANRH	2204054.00ON A/C	     JPBLRY	85261.00ON A/C	     JPSC	216617.00ON A/C	     JPTPTH	318560.00PAID	     JPTPTH	184937.00PAID	     JPBLRY	111139.00PAID	     JPANRH	179866.00PAID	     JPSC	71332.00TOPAY	     JPANRH	1248390.00TOPAY	     JPTPTH	596670.00TOPAY	     JPBLRY	333283.00TOPAY	     JPSC	1388396.00But what i want is the belowBooked_by    ON A/C     PAID     TOPAY     GrandTotal========================================================JPANRH         - - -     ----    ----- JPBLRYJPSCJPTPTHPlease help me out, how to generate this query.ThanksMadhukar |  |  
                                    | SwePesoPatron Saint of Lost Yaks
 
 
                                    30421 Posts | 
                                        
                                          |  Posted - 2013-08-13 : 05:43:58 
 |  
                                          | See PIVOT queries. Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA
 |  
                                          |  |  |  
                                |  |  |  |