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,861 of 19,505   
   Gints Plivna to All   
   Re: need help with ordering groups of re   
   23 Apr 13 05:19:15   
   
   From: gints.plivna@gmail.com   
      
   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   
      
   --- 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