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  | 
                             
                            
                                    | 
                                         usafelix 
                                        Posting Yak  Master 
                                         
                                        
                                        165 Posts  | 
                                        
                                        
                                            
                                            
                                             Posted - 2014-08-12 : 23:48:43
                                            
  | 
                                             
                                            
                                            | I want edit this query how i can to do this ?select item,sum(salesamt *saleqty) /sum(salesamt) as gp from saleheaderoutput item    amt        GP %apple   5.00       123.000000orange  20.00      83.000000000Want to change item       amt     GP %apple      5.00    %123orange     20.00   %80Total      25      Average GP         %13  | 
                                             
                                         
                                     | 
                             
       
                            
                       
                          
                            
                                    | 
                                     sz1 
                                    Aged Yak Warrior 
                                     
                                    
                                    555 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2014-08-13 : 05:25:14
                                          
  | 
                                         
                                        
                                          | select [item],[amt],[PercentofGP] = convert(varchar, convert(decimal(5,2), 100.0 * (salesamt) * (saleqty) / (salesamt))) + '%'from saleheaderselect [Total] = sum([item]),[AvgPercentofGP] = avg(convert(varchar,convert(decimal(5,2), 100.0 * (salesamt) * (saleqty) / (salesamt)))) + '%'from saleheaderWe are the creators of our own reality!  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                            
                                | 
                                    
                                      
                                     
                                    
                                 | 
                             
                         
                     | 
                 
             
         |