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  | 
                             
                            
                                    | 
                                         nhaas 
                                        Yak Posting Veteran 
                                         
                                        
                                        90 Posts  | 
                                        
                                        
                                            
                                            
                                             Posted - 2012-06-04 : 13:00:44
                                            
  | 
                                             
                                            
                                            | I am haning issues with MAX daxI have a table which is Name, dept, date1,aduserI can run "Select name,Max(date1) From Table group by name". but I want to see the dept also how can I run this. everytime I run this I dont get the Max date.How can I run "Select Name, dept,MAX(date1) group by name" | 
                                             
                                         
                                     | 
                             
       
                            
                       
                          
                            
                                    | 
                                     visakh16 
                                    Very Important crosS Applying yaK Herder 
                                     
                                    
                                    52326 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2012-06-04 : 13:08:22
                                          
  | 
                                         
                                        
                                          | [code]select t.*from Table tINNER JOIN (Select name,Max(date1) as maxdate            From Table             group by name           )t1on t1.name = t.nameand t1.maxdate = t.date1[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                       
                          
                            
                                    | 
                                     nhaas 
                                    Yak Posting Veteran 
                                     
                                    
                                    90 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2012-06-04 : 13:33:28
                                          
  | 
                                         
                                        
                                          | Thank you visakh16!  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                       
                          
                            
                                    | 
                                     visakh16 
                                    Very Important crosS Applying yaK Herder 
                                     
                                    
                                    52326 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2012-06-04 : 14:54:39
                                          
  | 
                                         
                                        
                                          | welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                       
                          
                            
                                    | 
                                     madhivanan 
                                    Premature Yak Congratulator 
                                     
                                    
                                    22864 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2012-06-05 : 05:21:46
                                          
  | 
                                         
                                        
                                          | orselect * from table as t1where date1=(Select Max(date1) From Table as t2 where t1.name=t2.name)MadhivananFailing to plan is Planning to fail  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                            
                                | 
                                    
                                      
                                     
                                    
                                 | 
                             
                         
                     | 
                 
             
         |