text
stringlengths
1
81
start
float64
0
10.1k
duration
float64
0
24.9
Let's try this one too.
3,967.3
1.8
I'll come back, and I'll say SELECT, again, ROUND average "rating" comma 2.
3,969.1
10.02
But now, I'll select it AS, let's say, average rating.
3,979.12
6.14
And now before I actually finish this query,
3,985.26
1.833
let me try to bring it up to the top my terminal so we can see it all in one
3,987.093
3.167
go.
3,990.26
0.57
I'll backspace this.
3,990.83
1.32
And I'll say SELECT the rounded version of the average rating rounded
3,992.15
8.3
to 2 decimal points AS--
4,000.45
2.31
let's call this one "average rating."
4,002.76
2.91
Now hit Enter.
4,005.67
1.11
And I'll say FROM my "longlist" table Semicolon.
4,006.78
4.59
Now, I see it's much prettier overall.
4,011.37
2.46
I have no longer these SQL keywords but instead
4,013.83
3.18
just average rating as my column name.
4,017.01
4.11
OK.
4,021.12
1.44
So let me pause here and ask questions then
4,022.56
2.4
on using average or using ROUND or using AS in these cases.
4,024.96
7.53
SPEAKER: I'm wondering, do these sorts of commands have a funct--
4,032.49
3.87
are these commands encode something like data types or just encode something?
4,036.36
5.4
Do these commands also have a name?
4,041.76
2.238
CARTER ZENKE: Yeah.
4,043.998
0.792
And can I ask are you referring to the AVG like COUNT like SUM
4,044.79
3.84
those kinds of things, or?
4,048.63
1.23
Yeah.
4,049.86
0.69
So these functions do have a name.
4,050.55
2.59
They are called aggregate functions.
4,053.14
1.61
And aggregate means to combine, to bring together.
4,054.75
3.1
So they're called aggregate functions because they take some number of rows,
4,057.85
3.56
like all my ratings for instance, and bring it down to one single cell,
4,061.41
4.2
like the average or the sum or the count.
4,065.61
2.92
So if you look up or read more about SQL aggregate functions,
4,068.53
3.5
you'll see all of these and perhaps some more
4,072.03
2.04
depending on the software you're using.
4,074.07
3.68
OK.
4,077.75
0.78
So let's keep going then and try to start counting some other rows
4,078.53
4.44
and use our other aggregate functions here.
4,082.97
1.98
I'll go back to my terminal.
4,084.95
1.89
And so far, we've seen average, as well as we have seen ROUND and so on.
4,086.84
6.3
But why don't I try to find the maximum or the minimum rating in my table?
4,093.14
5.46
I'll say SELECT, let's say, the MAX "rating" FROM my "longlist" Semicolon.
4,098.6
6.96
Hit Enter.
4,105.56
1.11
Now I see the highest rated book had a rating of 4.52.
4,106.67
4.859
Well, what about the minimum rating?
4,111.529
1.5
I could use MIN here too.
4,113.029
1.171
I could say SELECT, let's say, MIN of my "rating" column FROM my "longlist"
4,114.2
6.11
table.
4,120.31
0.69
I'll hit Semicolon.
4,121
1.71
And I'll see it 3.05.
4,122.71
1.979
It is the lowest-rated book I have in this set.
4,124.689
4.29
Well, as we've seen, let me try to view this for you all.
4,128.979
4.05
I could say SELECT "title" and "votes" FROM my "longlist."
4,133.029
6.361
SELECT "title" and "votes" from my "longlist."
4,139.39
2.04
Here, I have many books with many user-generated votes.
4,141.43
4.74
Maybe people on the internet decided to rate this book out of 5
4,146.17
3.57
and maybe Go, Went, Gone got about, let's say, 592 votes.
4,149.74
5.38
So I'm curious then, how many total votes do I have in my data set?
4,155.12
5.58
Well, for that, I could use the SUM aggregate function.
4,160.7
2.9
Try to count up each one of these rows and/or turn it back to me
4,163.6
4.259
in a single cell.
4,167.859
1.691
So I'll use SUM here.
4,169.55
1.429
I'll come back and I'll say I want to find the sum of my votes column.
4,170.979
5.25
I'll say SELECT, let's say, the SUM of my "votes" column
4,176.229
6.661
FROM my "longlist" table.
4,182.89
2.62
And then I'll just Enter--
4,185.51
1.219
Semicolon Enter.
4,186.729
1.231
And I'll see over 600,000 people offer to vote
4,187.96
4.71
for each of these books that were longlisted for the International Booker
4,192.67
4.14
Prize.
4,196.81
1.81
Now there'd be a few more here.
4,198.62
1.45
Let's check out what else we have left to do and our aggregate functions.
4,200.07
3.17
We could also try to count up just the number of books in our data set.
4,203.24
4.96
So why don't I try to find the number of rows I have?
4,208.2
3.71
For that, I could use count.
4,211.91
2.16
And often to find the number of rows in your data set,
4,214.07
3.03
you might use count and star as we saw a little earlier.
4,217.1
3.36
I could say SELECT COUNT star from "longlist"
4,220.46
4.74
And this means, again star means give me every row and every column.
4,225.2
5.07
Give me basically my whole table, right?
4,230.27
2.58
And if I say COUNT star, that means count up the number of rows
4,232.85
3.9
that I have in my database.
4,236.75
2.53
So I'll say COUNT star from "longlist."
4,239.28
2.27
And I get back 78 books in this database.
4,241.55
4.2
Well, let me try counting up the number of translators here.
4,245.75
2.97
I'll say SELECT, let's say, COUNT of "translators" FROM "longlist"
4,248.72
6.12
Semicolon.
4,254.84
1.05
Hit Enter.
4,255.89
1.41
And now I see 76.
4,257.3
3.37
So I have 78 books, but if I count translators, I have 76 of them.
4,260.67
8.01
So why might that be?
4,268.68
2.19
Free to raise your hand and try to guess at this.
4,270.87
3.21
Why do I have 78 rows but 76 translators?
4,274.08
4.973
SPEAKER: Hi.
4,279.053
0.947
I actually had raised my hand for the question.
4,280
2.412
CARTER ZENKE: Yeah, go ahead.
4,282.412
1.208
SPEAKER: Also, I wanted to know whether the MAX
4,283.62
2.59
and the MIN functions can be used for finding the longest or the shortest
4,286.21
3.81
string as well?
4,290.02
0.69
Or do you have a different command for that?
4,290.71
1.833
CARTER ZENKE: Good question.
4,292.543
1.167