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  | 
                             
                            
                                    | 
                                         stamford 
                                        Starting Member 
                                         
                                        
                                        47 Posts  | 
                                        
                                        
                                            
                                            
                                             Posted - 2015-01-15 : 18:24:04
                                            
  | 
                                             
                                            
                                            Is there a way to sort the before table so it looks like the after table, so that Original_ID values are still grouped together, but not necessarily in numerical order, and the IsoDate values are sorted descending. Empty or NULL IsoDate values need no special attention and can fall where they will, as long as the Original_ID values are kept together.BeforeOriginal_ID	ID	IsoDate147	        147	20/08/2009147	        7621	20/08/20092221	        2221	2221	        7620	14/01/20152221	        7623	14/01/20157500	        7500	16/10/20147500	        7619	16/10/2014AfterOriginal_ID	ID	IsoDate147	        147	20/08/2009147	        7621	20/08/20097500	        7500	16/10/20147500	        7619	16/10/20142221	        2221	2221	        7620	14/01/20152221	        7623	14/01/2015  | 
                                             
                                         
                                     | 
                             
       
                            
                       
                          
                            
                                    | 
                                     nagino 
                                    Yak Posting Veteran 
                                     
                                    
                                    75 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2015-01-15 : 19:50:33
                                          
  | 
                                         
                                        
                                          Take it easy.Use ORDER BY clause only like following.SELECT	Original_ID,	ID,	IsoDateFROM YourTableORDER BY	MAX(IsoDate) OVER(PARTITION BY Original_ID) ASC,	ID ASC -------------------------------------From JapanSorry, my English ability is limited.  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                            
                                | 
                                    
                                      
                                     
                                    
                                 | 
                             
                         
                     | 
                 
             
         |