text stringlengths 1 81 | start float64 0 10.1k | duration float64 0 24.9 |
|---|---|---|
And there is a way for me to
get back just to some of them | 994.183 | 2.417 |
later on that we'll see. | 996.6 | 1.32 |
But for now, let's
ask, what questions do | 997.92 | 2.64 |
you have on this SQL SELECT statement
and how we're getting back these rows? | 1,000.56 | 6.62 |
SPEAKER: Do I need to use the quotes
around the words like you are? | 1,007.18 | 3.532 |
CARTER ZENKE: Yeah, great question. | 1,010.712 | 1.458 |
Do I have to use quotes
around the words like I am? | 1,012.17 | 2.96 |
In general, it's a good practice to use
these double quotes around your table | 1,015.13 | 4.44 |
names and your column names. | 1,019.57 | 1.86 |
These are called SQL identifiers. | 1,021.43 | 2.49 |
Later on, we'll see we'll also
have strings in SQL-- strings | 1,023.92 | 4.26 |
being collections of
characters we can use. | 1,028.18 | 1.86 |
For those, we'll simply
single-quote them | 1,030.04 | 2.279 |
to note the difference between a
string and an actual column name. | 1,032.319 | 4.121 |
So good style convention here to
use-- double quotes for column names | 1,036.44 | 3.53 |
and single quotes for string names. | 1,039.97 | 3.33 |
Other questions too? | 1,043.3 | 1.89 |
SPEAKER: OK. | 1,045.19 | 0.55 |
I wanted to know, where did we
take all this information from. | 1,045.74 | 4.25 |
Like, this data, I don't
know this list of books, | 1,049.99 | 4.35 |
where did we take all
this information from? | 1,054.34 | 2.298 |
CARTER ZENKE: Yeah, a great question. | 1,056.638 | 1.542 |
Where do we take this information from? | 1,058.18 | 1.81 |
So some of this data
is publicly available. | 1,059.99 | 2.28 |
In fact, if you look at
the Booker Prize website, | 1,062.27 | 2.42 |
you can find a set of
longlisted books over the years. | 1,064.69 | 3.09 |
In this case, we have
books from 2018 to 2023. | 1,067.78 | 3.87 |
We'll also see later on this table
has data on the ratings of those books | 1,071.65 | 5.238 |
and the number of votes that
were given to those books. | 1,076.888 | 2.292 |
That data is from Goodreads,
the site that aggregates | 1,079.18 | 3.45 |
reviews from people like you, people
like me who rate books online. | 1,082.63 | 4.3 |
So we've taken data from a variety of
sources and combined it into one here. | 1,086.93 | 4.45 |
Let's take one more
question to from Vinayak. | 1,091.38 | 3.117 |
SPEAKER: Yeah. | 1,094.497 | 0.583 |
So I wanted to ask regarding the syntax
of what you used in the terminal. | 1,095.08 | 5.26 |
So is the whole SQLite
3 is case-sensitive | 1,100.34 | 4.49 |
because while using the syntax you
used capital letters, whereas can we | 1,104.83 | 5.19 |
use small-case letters as well? | 1,110.02 | 2.548 |
CARTER ZENKE: A great question. | 1,112.568 | 1.292 |
So here, I used capital
letters for SQL keywords | 1,113.86 | 2.72 |
and lowercase, my table
names and column names. | 1,116.58 | 2.7 |
Do I have to do that? | 1,119.28 | 1.53 |
I, in some cases, do, some cases don't. | 1,120.81 | 2.4 |
I think I could use lowercase
for these SQL keywords, | 1,123.21 | 3.18 |
but it's not very good
style, for instance. | 1,126.39 | 2.47 |
So let me just show you an example of
this while I go back to my computer. | 1,128.86 | 3.6 |
So the question again was, can I
use lowercase for SQL keywords? | 1,132.46 | 5.09 |
I think I could, but the
question is, should I? | 1,137.55 | 3.3 |
And probably not. | 1,140.85 | 0.768 |
So let me try this. | 1,141.618 | 0.792 |
I'll say select, let's say, title from-- | 1,142.41 | 3.035 |
I'm in the habit of uppercase it. | 1,145.445 | 1.375 |
So I'll say from in lowercase
longlist like this Semicolon. | 1,146.82 | 4.83 |
Hit Enter. | 1,151.65 | 0.96 |
And that still works. | 1,152.61 | 1.86 |
But the problem you
might run into is someone | 1,154.47 | 2.64 |
who's reading your query particularly,
a long one, might want to know, | 1,157.11 | 4.05 |
what are the SQL keywords? | 1,161.16 | 1.65 |
And what are your column names
and other identifiers here? | 1,162.81 | 3.57 |
By capitalizing your SQL
keywords, you can make it clear | 1,166.38 | 3.03 |
that this is a SQL keyword and
not some other name overall. | 1,169.41 | 5.87 |
OK. | 1,175.28 | 0.6 |
So let's keep going. | 1,175.88 | 1.14 |
And we saw just a little bit ago that
we could select "title" from "longlist." | 1,177.02 | 4.77 |
And we would get back a whole list of
titles, literally all the titles that | 1,181.79 | 4.56 |
are in this database. | 1,186.35 | 2.05 |
But it's often maybe good practice
for me to not look at all the data. | 1,188.4 | 4.7 |
Like, imagine if we had
millions of rows in this column, | 1,193.1 | 3.33 |
but only to give back some. | 1,196.43 | 1.56 |
Take a peek of what's
inside this database. | 1,197.99 | 2.7 |
And for that, I could use this other
SQL keyword, this one called LIMIT. | 1,200.69 | 5.13 |
So LIMIT, as its name
might imply, limits | 1,205.82 | 3.3 |
the number of queries or the number
of rows I get back from my query. | 1,209.12 | 3.93 |
I could say LIMIT 3,
for instance, or LIMIT 5 | 1,213.05 | 3.15 |
to get back only the top 3 or
the top 5 rows from my table. | 1,216.2 | 3.93 |
And let me ask folks,
if I wanted to peak | 1,220.13 | 2.37 |
in this data set, how many rows
should I try to limit it to? | 1,222.5 | 5.39 |
I could say SELECT
title from, let's say, | 1,227.89 | 2.31 |
longlist, but limit to what number? | 1,230.2 | 3.76 |
I'm seeing 10. | 1,233.96 | 1.14 |
So let's try 10 first. | 1,235.1 | 1.25 |
I'll go back to my computer. | 1,236.35 | 1.83 |
I'll come back over here,
and I'll say, why don't I | 1,238.18 | 2.43 |
select "title" from "longlist?" | 1,240.61 | 5.09 |
But now, instead of hitting Semicolon,
I will instead say LIMIT 10 Semicolon. | 1,245.7 | 7.98 |
And I'll hit Enter. | 1,253.68 | 1.29 |
Now I see only the first
10 rows in my data set. | 1,254.97 | 5.04 |
Handy for peeking in at the
top of my data set here too. | 1,260.01 | 3.37 |
Let me try not just 10 but 5. | 1,263.38 | 1.83 |
So I'll say SELECT "title" from
"longlist" LIMIT 5 Semicolon. | 1,265.21 | 8.7 |
This then gives me just the
top 5 titles in my database. | 1,273.91 | 5.465 |
Just in whatever order they
were added to my table, | 1,279.375 | 2.125 |
I'll see them in that order here too. | 1,281.5 | 4.3 |
So using LIMIT, we can actually try
to get back a certain number of rows. | 1,285.8 | 5.32 |
But this isn't quite that interesting. | 1,291.12 | 2.625 |
It's good for peaking in your data set. | 1,293.745 | 1.625 |
I think we've answered that
question of, what data do we have? | 1,295.37 | 2.83 |
But let's say we want to
make more advanced queries. | 1,298.2 | 2.75 |
We want to find the books that were
nominated in 2023 or perhaps books | 1,300.95 | 3.63 |
by a certain author. | 1,304.58 | 1.23 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.