What does order by 1 or 2 mean in a windows function order by clause?

What exactly is the order by clause doing in the following SQL statement?

 SELECT MemberId,SubscriberId,insurance_Type, RANK() OVER ( ORDER BY CASE WHEN insurance_Type = 'primary' THEN 1 WHEN insurance_Type = 'secondary' THEN 2 END ) InsuranceTypePriority FROM Insurances 

I understand that in the end any row with “primary” will come before any row with “secondary” but I don’t understand exactly what the SQL is doing. What does it mean to order something by 1 or by 2?
How does this case statement work? How would I explain this statement using words like
if insurance type is primary then order by 1… which means what exactly?

submitted by /u/Far_Calligrapher_215
[link] [comments]


Go to Source of this post
Author Of this post: /u/Far_Calligrapher_215
Title Of post: What does order by 1 or 2 mean in a windows function order by clause?
Author Link: {authorlink}