home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.databases.ms-sqlserver      Notorious Rube Goldberg contraption      19,505 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 18,866 of 19,505   
   migurus to Gints Plivna   
   Re: need help with ordering groups of re   
   30 Apr 13 10:13:44   
   
   From: migurus@yahoo.com   
      
   On Tuesday, April 23, 2013 5:19:15 AM UTC-7, Gints Plivna wrote:   
   > ceturtdiena, 2013. gada 18. aprīlis 04:21:02 UTC+3, migurus rakstīja:   
   >    
   > > I have a list of customers and addresses they have visited, each record   
   has a count of visits. I need to re-sort the list in such a way that customers   
   with higher counts will be higher on the list, but all his/her records should   
   stay together   
   >    
   > >    
   >    
   > [skipped]   
   >    
   > >    
   >    
   > > As you see, Juan Silva has 225 visits, which is highest of them all, so   
   all his records are sorted before everybody else. The order of records within   
   group belonging to the same customer is not important.   
   >    
   > >    
   >    
   > >    
   >    
   > >    
   >    
   > > Any hint or idea would be appreciated.   
   >    
   >    
   >    
   >    
   >    
   > select * from @t t   
   >    
   > order by MAX(cnt) OVER (PARTITION BY NAME) desc, cnt desc   
   >    
   >    
   >    
   > Gints Plivna   
   >    
   > http://www.gplivna.eu   
      
   Thank you it works   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca