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  | 
                             
                            
                                    | 
                                         jdeforums 
                                        Starting Member 
                                         
                                        
                                        8 Posts  | 
                                        
                                        
                                            
                                            
                                             Posted - 2014-02-21 : 06:24:09
                                            
  | 
                                             
                                            
                                            | Hi,I required Subtotal based on branch wise and Grand total.My current query is Select SDMCU as Branch,ABAC29_DESC as Sales,ABAC30_DESC as Type,round(sum(case when invoice_date=dateadd(day,datediff(day,0,getdate()),-1) then order_qty*unit else 0 end)/1000000,2) as Previousday_Sales_Million,round(sum(order_qty*unit)/1000000,2) as MTD_Sales_Million from sales where invoice_date >= dateadd(month,datediff(month,0,getdate()),0) and invoice_date < dateadd(month,datediff(month,0,getdate())+1,0) group by ABAC29_desc,abac30_desc,sdmcu order by sdmcuAnd required output is          ITM	3rd	Other	0	2.64         ITM	3rd	Home	0	0.06         ITM	Inter	Home	0.96	15.45Total			        0.96	18.15         ITR	3rd	Other	1.22	2.24         ITR	3rd	Home	0	0.23         ITR	Inter	Home	0.44	24.26Total			        1.66	26.73Grand Total		      	2.62	44.88Please help me to create the query based on my requestThanks in advanceSuresh.K.P | 
                                             
                                         
                                     | 
                             
       
                            
                            
                                | 
                                    
                                      
                                     
                                    
                                 | 
                             
                         
                     | 
                 
             
         |   
     
     
            
              
	     |  
		
			
     
          
		 |