Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,390 --> 00:00:04,320
Now there are two more functions that are similar to rule number.
2
00:00:04,980 --> 00:00:07,260
The first one is rank.
3
00:00:08,120 --> 00:00:11,870
So I will tell you the difference from this example.
4
00:00:12,800 --> 00:00:18,780
So just like in the raw number here, we have three columns customer, store and order.
5
00:00:18,800 --> 00:00:20,660
In fact, we have the same data.
6
00:00:22,610 --> 00:00:34,400
Now, if I apply rank instead of row number, it will again create partition, sort my data and provide
7
00:00:34,400 --> 00:00:37,940
row number or rank in a new column.
8
00:00:38,240 --> 00:00:40,580
So just like row number here.
9
00:00:40,580 --> 00:00:43,100
Also I will get one, two, three.
10
00:00:43,980 --> 00:00:45,210
For a store.
11
00:00:45,240 --> 00:00:46,530
A with order.
12
00:00:46,530 --> 00:00:47,610
Six, three, two.
13
00:00:49,320 --> 00:00:52,080
But for a store B.
14
00:00:53,270 --> 00:00:56,540
I will get 1 to 2 for.
15
00:00:57,320 --> 00:01:00,380
So if there is a tie.
16
00:01:01,810 --> 00:01:06,730
I am providing these raw numbers on the basis of number of orders.
17
00:01:06,730 --> 00:01:16,600
So if there is a tie on orders, rank will provide the same ring to all the tied values.
18
00:01:17,520 --> 00:01:19,770
So in row number.
19
00:01:19,920 --> 00:01:21,300
We saw that.
20
00:01:22,230 --> 00:01:31,530
It provided rule number of two to C three and row number of three to see six because C three was appearing
21
00:01:31,530 --> 00:01:33,570
first in our table.
22
00:01:33,720 --> 00:01:41,370
So that's why it provided two to see three and three to see six.
23
00:01:42,950 --> 00:01:48,440
Even though the number of orders for both of these customers were same.
24
00:01:49,400 --> 00:01:56,900
But in the rank we will get the same number of ranking to both the customers.
25
00:01:58,210 --> 00:02:07,720
One more important point is after ranking this customer so C three and see six are both getting row
26
00:02:07,720 --> 00:02:09,490
number or rank as two.
27
00:02:10,000 --> 00:02:13,330
After this it will directly jump to four.
28
00:02:14,830 --> 00:02:20,230
So to the fourth or the last customer, it will give a rank of four.
29
00:02:20,260 --> 00:02:21,600
It will not give three.
30
00:02:21,610 --> 00:02:26,290
It will give four because there are two customers on rank two.
31
00:02:26,320 --> 00:02:30,430
That's why it is giving four to the next customer.
32
00:02:30,820 --> 00:02:37,750
If there are three customers on rank, two then to the next customer it will provide five.
33
00:02:39,030 --> 00:02:44,400
So when you are using rank, it will escape some ranks in between.
34
00:02:45,300 --> 00:02:48,600
The formula and the syntax is almost same.
35
00:02:48,720 --> 00:02:52,440
Just instead of raw number, you have to use rank.
36
00:02:53,410 --> 00:02:58,630
Now another variation of rule number and rank is dense rank.
37
00:02:59,510 --> 00:03:00,590
And dancing.
38
00:03:00,620 --> 00:03:03,890
The only difference is here in rank.
39
00:03:03,890 --> 00:03:06,770
We were skipping number three then.
40
00:03:06,890 --> 00:03:09,350
Rank will never skip any rank.
41
00:03:09,470 --> 00:03:16,370
So even if there are three customer on rank two to the fifth customer, it will provide rank three.
42
00:03:16,460 --> 00:03:25,880
So there is no skipping of rank and dense rank and there is a skipping of rang and rang function.
43
00:03:28,920 --> 00:03:31,140
Intense drink and drink.
44
00:03:31,650 --> 00:03:34,860
There are same ranking for tide values.
45
00:03:35,650 --> 00:03:36,730
In raw number.
46
00:03:37,030 --> 00:03:40,900
All the rows within the partition will have the unique value.
47
00:03:41,970 --> 00:03:44,540
So remember these three functions.
48
00:03:44,550 --> 00:03:50,370
The difference between these three are asked frequently in many interview questions.
49
00:03:51,710 --> 00:03:57,530
So once again, I'll repeat in row number, all the rows will be unique within a partition.
50
00:03:58,260 --> 00:03:59,880
In rank and dancing.
51
00:03:59,880 --> 00:04:03,360
There can be same ranking on tide values.
52
00:04:04,840 --> 00:04:08,950
And there is no skipping of rank and dense rank.
53
00:04:08,980 --> 00:04:11,500
As the name suggests, densely ranked.
54
00:04:12,340 --> 00:04:19,000
And there will be a skipping of ranks in rank function if there is a tie.
55
00:04:20,380 --> 00:04:21,640
Again for dense ring.
56
00:04:21,640 --> 00:04:24,070
Also, the syntax is almost same.
57
00:04:24,730 --> 00:04:28,660
Just instead of rule number or rank, you have to use dense rank.
58
00:04:29,700 --> 00:04:32,880
Now let's apply this in our data.
59
00:04:34,350 --> 00:04:38,310
So in our last lecture, we created row and variable.
60
00:04:39,540 --> 00:04:45,570
Now let's create rank and then rank variable in the same table.
61
00:04:46,170 --> 00:04:48,630
So I will just copy paste this.
62
00:04:51,530 --> 00:04:53,630
For ring, we will rate the ring.
63
00:04:54,080 --> 00:04:56,120
And here also I will rate.
64
00:04:57,340 --> 00:04:59,950
I will name this column as rank number.
65
00:05:01,900 --> 00:05:04,990
And similarly for dance.
66
00:05:04,990 --> 00:05:07,810
Ring will write dance.
67
00:05:08,700 --> 00:05:15,390
Ranke and I will save this column as drink.
68
00:05:22,850 --> 00:05:24,430
Now let's run this.
69
00:05:26,760 --> 00:05:31,680
There is an additional comma will remove it and then run it again.
70
00:05:36,440 --> 00:05:39,380
So you can see that if there is no tie.
71
00:05:40,570 --> 00:05:42,400
We are getting the same values.
72
00:05:42,970 --> 00:05:46,960
But here in this row, we have a tie.
73
00:05:47,940 --> 00:05:58,680
So for customer 80 705 and 615, both have number of orders as eight in state of Alabama.
74
00:05:59,250 --> 00:06:04,980
So in case of roll number, we are getting 1 to 3 in case of rank.
75
00:06:05,010 --> 00:06:11,450
I'm getting 1 to 2 and in case of dense ring, also I'm getting 1 to 2.
76
00:06:11,790 --> 00:06:17,490
But for the next customer, we are getting one, two, three, four in the roll number.
77
00:06:17,940 --> 00:06:21,420
We are getting one, two, two, four in rank.
78
00:06:21,420 --> 00:06:25,050
And because we are skipping ranked number three.
79
00:06:25,410 --> 00:06:29,010
But in the dense ring, we are getting one, 2 to 3.
80
00:06:29,010 --> 00:06:32,250
So we are not skipping any rank in dense ring.
81
00:06:33,580 --> 00:06:37,180
You can also look at this for customers from California.
82
00:06:37,180 --> 00:06:43,320
So you can see that there are multiple customers with number of orders as well.
83
00:06:43,330 --> 00:06:47,740
So there are four customers with number of orders as well in California.
84
00:06:48,910 --> 00:06:54,490
For these customers, we are getting three, three, three, three in rank and then seven.
85
00:06:55,210 --> 00:06:59,650
But in dancing we are getting to 2 to 2 and then three.
86
00:07:01,680 --> 00:07:06,450
We are getting to hear instead of three because there are two people in rank one.
87
00:07:07,250 --> 00:07:12,740
So we are skipping number to four, five, six and so on.
88
00:07:13,520 --> 00:07:18,050
So this is the difference between row number, rank and dense rank.
7750
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.