SQL Tech Insider-usage of 6 rank () over (order by XX COLLATE)

Source: Internet
Author: User

DECLARE @Names TABLE (  name VARCHAR), INSERT into @Names VALUES  (' Deszmetch '), (' Deszmetch '), (' Deszmetck '), (' Deszmetch '), (' Deszmetch '); SELECT  name,  RANK () over (ORDER by name COLLATE Latin1_General_BIN) as [Lat ... BIN],  RANK () over (ORDER by name COLLATE traditional_spanish_ci_as) as [Tra ... Ci_as],  RANK () over (ORDER by name COLLATE latin1_general_cs_as) as [Lat ... Cs_as],  RANK () over (ORDER by name COLLATE latin1_general_ci_as) as [Lat ... Ci_as],  RANK () over (ORDER by name COLLATE hungarian_ci_as) as [Hun..._ci_as]from @NamesORDER by name COLLATE Latin1_g Eneral_bin; GO

---order do not follow the fields can be different, but will be in the last sort order

DECLARE @Student Table   --Student score table (ID int,  --primary key Grade int,--Class score int,--score name VARCHAR ()-  -name) INSERT int O @Student VALUES (1,1,88, ' A1 '), (2,1,66, ' B1 '), (3,1,75, ' C1 '), (4,2,30, ' D1 '), (5,2,70, ' E1 '), (6,2,80, ' F1 '), (7,2,60, ' G1 ') '), (8,3,90, ' H1 '), (9,3,70, ' I1 '), (10,3,80, ' J1 ')--select * from  @StudentSELECT Name,score,rank () over (ORDER by Grade DESC) as Rankgrade,rank () over (order BY score Desc) as Rankscore,rank () over (order by ID DESC) as Rankidfrom  @St Udent

  

SQL Tech Insider-usage of 6 rank () over (order by XX COLLATE)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.