text
stringlengths
1
81
start
float64
0
10.1k
duration
float64
0
24.9
So let me hit Enter here.
3,278.84
1.85
And I'll get back, well, not quite the top 10.
3,280.69
5.36
I see rating of 3.05 here and rating of 3.42 down here.
3,286.05
6.19
So based on this, what do you think the default ordering of ORDER BY is?
3,292.24
7.76
So you might be from least to greatest.
3,300
2.02
So we saw here that we have rating being pretty small,
3,302.02
3.41
but we said ORDER BY our rating.
3,305.43
1.71
So it starts from small and goes down to large.
3,307.14
3.3
So we need to fix this in some way.
3,310.44
1.98
And let's introduce a new addition to ORDER BY
3,312.42
2.82
to have us fix this query overall.
3,315.24
3.58
So let me show you that ORDER BY does by default sort from least to greatest.
3,318.82
6.11
But let's try some addition here.
3,324.93
2.64
We have not just ORDER BY but ORDER BY some column
3,327.57
4.26
and then ascending or descending.
3,331.83
3.7
So ascending is the default. It means from least to greatest.
3,335.53
3.95
Descending, we can specify meaning from greatest to smallest.
3,339.48
4.78
So let's try using ORDER BY but now with this other keyword
3,344.26
3.05
called DESC for descending here.
3,347.31
3.21
I'll go back to my terminal.
3,350.52
3.24
And let's rewrite this query to include DESC.
3,353.76
3.45
I'll say SELECT "title" and "rating" from "longlist."
3,357.21
5.49
And let me-- before I run this query, let
3,362.7
1.932
me just clear my terminal so it's back up at the top.
3,364.632
2.208
I'll backspace this.
3,366.84
1.74
And then a moment here, I'll press Control-L. Now I'm back at the top.
3,368.58
4.47
I'll say SELECT "title", SELECT "title" and "rating" from "longlist" WHERE--
3,373.05
8.797
actually, not WHERE.
3,381.847
0.833
We're not filtering yet.
3,382.68
1.14
I'll say ORDER BY rating but not by ascending by default--
3,383.82
6.262
going from least to greatest.
3,390.082
1.208
I want greatest to least.
3,391.29
1.72
So I'll say DESC here.
3,393.01
2.36
Now, I can say LIMIT 10 Semicolon.
3,395.37
3.51
Hit Enter.
3,398.88
0.96
And now I'll see the top 10 books.
3,399.84
2.7
Here, I have The Eighth Life coming in at 4.52 and The Books of Jacob
3,402.54
4.62
coming in at 4.06.
3,407.16
2.52
So now we're going from greatest to smallest.
3,409.68
3.78
Well, I could order by not just these ratings,
3,413.46
3.42
but also by the number of votes.
3,416.88
2.34
It seems there's a tie to break here.
3,419.22
1.68
If I look at Still Born and When We Cease to Understand the World,
3,420.9
3.99
those both have a rating of 4.14.
3,424.89
2.91
But presumably, one book has maybe more votes than the other.
3,427.8
4.63
So I could try to break this tie by ordering not just by rating but also
3,432.43
5.93
by votes, the number votes this book actually received on Good Reads.
3,438.36
4.17
So let's try that then to break this tie.
3,442.53
2.76
I'll come back over here.
3,445.29
1.44
And I'll try this query now.
3,446.73
2.76
I'll say, again, SELECT "title" and "rating" from "longlist."
3,449.49
6.3
Now I'll order by, first, the rating column in descending order.
3,455.79
6.07
But I also want to order by the number of votes after I order by rating.
3,461.86
5.24
So I'm saying first order by rating, but afterwards,
3,467.1
3.63
followed by a comma, let's order by the number of votes
3,470.73
3.48
also in descending order-- from greatest to smallest.
3,474.21
4.29
Now I'll just continue my query on the next line.
3,478.5
2.67
And I'll say LIMIT 10 Semicolon.
3,481.17
2.91
This then gives me, let's see, the books but now
3,484.08
5.04
they're going to be in the order that allows us to see the number of votes.
3,489.12
3.85
Let me just actually refine this.
3,492.97
1.41
Let me say not just title and rating, let's make
3,494.38
2.732
sure we can see the votes here too.
3,497.112
1.458
So SELECT "title" and "rating" and "votes" from "longlist."
3,498.57
5.01
Hit Enter on my query.
3,503.58
1.23
Now I'll say ORDER BY "rating" and "votes."
3,504.81
2.94
Then I'll say LIMIT 10.
3,507.75
1.8
And here, I'm just getting the Up Arrow on my computer.
3,509.55
2.61
I'll hit Enter.
3,512.16
1.5
And now I'll see the votes included.
3,513.66
2.49
So let me show you this on the big screen.
3,516.15
1.92
Here, we see that the tie is broken.
3,518.07
2.37
So when we cease to understand the world,
3,520.44
2.16
these both have 4.14 along with Still Born.
3,522.6
3.96
But here, this book has more votes and so is higher in our order
3,526.56
4.98
now that we've ordered by multiple columns.
3,531.54
4.37
So let me pause here and ask what questions
3,535.91
2.33
we have on ordering with data.
3,538.24
3.39
Ordering by one column or multiple, and how we can sort data like this.
3,541.63
5.85
SPEAKER: Sir, I want to know that can we write rating to 4.93 to 4.9?
3,547.48
6.875
CARTER ZENKE: Yeah good question.
3,554.355
1.375
I think if I understand you correctly, how can we select a rating
3,555.73
2.85
or try to find a rating that's like equal to 4.92 or things like that.
3,558.58
4.24
Let's try that here.
3,562.82
0.96
So if I want to find a particular rating,
3,563.78
2.57
I could simply use my WHERE friend from before.
3,566.35
3.9
I could say SELECT, let's say, "title" and "rating."
3,570.25
4.14
And maybe I could try to find a particular rating for a book
3,574.39
3.36
from longlist.
3,577.75
1.65
I could say then WHERE this rating is equal to, let's say, 4.932 Semicolon.
3,579.4
7.47
If this book exists, it will get it back here.
3,586.87
2.29
So I'll hit Enter.
3,589.16
1.01
And I see there's no book with this particular rating, 4.392.
3,590.17
5.64
But good question for how to find particular ratings for our books here.
3,595.81
5.7
OK.
3,601.51
0.87
Other questions too on how we've been able to sort our data and use ORDER BY?
3,602.38
6.75
SPEAKER: Will descend work on a string on an alphabetic basis?
3,609.13
3.87
Or do we need to have special conditions for alphabetic characters?
3,613
5.098
CARTER ZENKE: Yeah, a great question.
3,618.098
1.542
So how could we use ORDER BY with some characters or strings or some text
3,619.64
4.1