text stringlengths 1 81 | start float64 0 10.1k | duration float64 0 24.9 |
|---|---|---|
So I know that these books
have a certain rating, | 2,940.97 | 2.54 |
but how many votes do they really get? | 2,943.51 | 2.22 |
Well, let's take a peek. | 2,945.73 | 1.48 |
I'll come back over here. | 2,947.21 | 1.25 |
And let me try this one. | 2,948.46 | 2.34 |
I could say SELECT "title." | 2,950.8 | 2.98 |
Oops, let me clear my terminal
again so it's back up top. | 2,953.78 | 3.34 |
SELECT "title" and
"rating" and the number of | 2,957.12 | 5.76 |
votes that these books got from,
let's say, our "longlist" table. | 2,962.88 | 5.16 |
Now, I want to find those that
have a rating of greater than 4.0, | 2,968.04 | 6.36 |
and, let's say, a number of votes-- | 2,974.4 | 4.28 |
a number of votes which
is greater than at least-- | 2,978.68 | 2.4 |
let's go with 10,000. | 2,981.08 | 2.25 |
So at least we know a good number of
folks actually voted on these books | 2,983.33 | 3.63 |
to find the best among them. | 2,986.96 | 2.01 |
I'll Enter. | 2,988.97 | 1.02 |
And now I'll see we're
only down to a few books, | 2,989.99 | 3.63 |
four in fact, where each one
has a rating higher than 4.0. | 2,993.62 | 4.65 |
And indeed, every vote row has a vote
total greater than 10,000 in this case. | 2,998.27 | 8.22 |
So a good way to try to find the
top books in our data set here. | 3,006.49 | 5.61 |
Let's keep going with these ranges. | 3,012.1 | 1.82 |
And let's think about one
more thing we could do. | 3,013.92 | 3.27 |
Maybe I want to find books that
are less than a certain length. | 3,017.19 | 2.85 |
So I'll try that as well. | 3,020.04 | 1.65 |
I'll say SELECT, let's say, "title"
and "pages" from my "longlist." | 3,021.69 | 5.49 |
And now I can make a
condition based on pages. | 3,027.18 | 2.82 |
I'll say WHERE "pages" is less than 300. | 3,030 | 3.69 |
Hit Enter. | 3,033.69 | 1.11 |
And now I should see that
I have all these books that | 3,034.8 | 3 |
are less than 300 pages long
when they were first published. | 3,037.8 | 5.47 |
So let's pause here
and ask what questions | 3,043.27 | 2.06 |
we have on these range conditions. | 3,045.33 | 3.69 |
SPEAKER: I just wanted to check
if for a proper query in this case | 3,049.02 | 6.21 |
to be able to run operations, they
have to be integers in the database. | 3,055.23 | 5.01 |
And my second question is for
when we're matching a string, | 3,060.24 | 3.84 |
is it case-sensitive or not? | 3,064.08 | 2.123 |
CARTER ZENKE: Yeah, two great questions. | 3,066.203 | 1.667 |
So the first one here is going to be,
do I have to use integers in this case? | 3,067.87 | 4.65 |
And what types, maybe, should I use? | 3,072.52 | 1.79 |
And the second one being, could I
match strings like case insensitively? | 3,074.31 | 3.54 |
So for the first one,
in this case, it'll | 3,077.85 | 3.09 |
depend on the design of your database. | 3,080.94 | 2.17 |
So we'll see later on
in the course, how we | 3,083.11 | 2.03 |
can choose the types for our columns. | 3,085.14 | 2.28 |
And how that might impact the types
we actually use in our queries. | 3,087.42 | 3.84 |
For now, I made this database. | 3,091.26 | 2.14 |
So I just know that my
year column is an integer, | 3,093.4 | 3.35 |
my ratings column is a real number
or a float, if you're familiar, | 3,096.75 | 3.27 |
and my votes is an integer. | 3,100.02 | 1.54 |
So I just know to use
those numbers there. | 3,101.56 | 2.24 |
To the question of matching
things case-insensitively, | 3,103.8 | 3.66 |
let's actually revisit LIKE just briefly
here to show you what that can do. | 3,107.46 | 3.36 |
So I go back to my terminal, and let's
say I want to find just a book title. | 3,110.82 | 7.34 |
And I want to type it
in kind of sloppily. | 3,118.16 | 1.75 |
I don't want to capitalize
it like capital books are. | 3,119.91 | 2.208 |
So I'll say SELECT let's
say "title" from "longlist." | 3,122.118 | 4.632 |
And maybe, I'll want to
find that book Pyre again. | 3,126.75 | 4.18 |
So I could say WHERE "title" is
LIKE 'pyre', but all in lowercase. | 3,130.93 | 6.78 |
Now I'll hit Enter. | 3,137.71 | 1.4 |
And I'll see I do get back Pyre. | 3,139.11 | 2.43 |
So even though I said WHERE "title"
is LIKE lowercase 'pyre', I got back | 3,141.54 | 5.97 |
capital Pyre. | 3,147.51 | 2.37 |
Now this is in contrast to saying
WHERE "title" equals lowercase 'pyre'. | 3,149.88 | 5.22 |
Let's try that. | 3,155.1 | 1.51 |
I'll come back over here. | 3,156.61 | 1.22 |
And I'll say again SELECT
"title" from "longlist," | 3,157.83 | 5.73 |
but now WHERE "title" equals,
quote, unquote, 'pyre' Semicolon. | 3,163.56 | 9.27 |
I'll hit Enter. | 3,172.83 | 0.96 |
And now I see no results. | 3,173.79 | 1.78 |
So in this case, the equal is
going to be case-sensitive. | 3,175.57 | 3.44 |
Case matters in this case,
but LIKE is case-insensitive. | 3,179.01 | 6.31 |
OK. | 3,185.32 | 1.67 |
Why don't we keep going then? | 3,186.99 | 2.858 |
And let's take a look
at a few other things | 3,189.848 | 1.792 |
we can do with these SQL
keywords for querying. | 3,191.64 | 3.81 |
Well, earlier, we were
trying to find a way | 3,195.45 | 2.79 |
to find the best books in our data set. | 3,198.24 | 3.24 |
And we did that by filtering
them based on some ranges. | 3,201.48 | 3.33 |
But we could probably do
that a little bit more | 3,204.81 | 2.4 |
methodically in this case using a new
keyword, this one called ORDER BY. | 3,207.21 | 5.97 |
So ORDER BY allows us to
take the results of our query | 3,213.18 | 4.8 |
and order them, as it suggests,
by some column itself. | 3,217.98 | 5.02 |
So we could put them in alphabetical
order or in order by a number of votes | 3,223 | 4.67 |
or in order by number of ratings. | 3,227.67 | 2.67 |
And let's just try an example of this
to see how ORDER BY works for us. | 3,230.34 | 4.02 |
But in the end, we'll see it can
arrange columns, arrange rows for us | 3,234.36 | 4.35 |
in our resulting query. | 3,238.71 | 1.72 |
So I'll go back to my computer. | 3,240.43 | 2.36 |
And let's try this question here. | 3,242.79 | 2.04 |
I want to try to find the
top 10 books in my table. | 3,244.83 | 4.57 |
So I'll say SELECT "title"
and "rating" from "longlist." | 3,249.4 | 7.48 |
Enter. | 3,256.88 | 1.2 |
Not only query yet though. | 3,258.08 | 1.74 |
Now I'll say ORDER BY the rating. | 3,259.82 | 4.82 |
And let's only take the top 10. | 3,264.64 | 2.16 |
So I'll say limit 10 in
this instance Semicolon. | 3,266.8 | 4.32 |
So now I've combined some
of my prior keywords. | 3,271.12 | 3.21 |
I'm using SELECT. | 3,274.33 | 1.17 |
I'm using ORDER BY. | 3,275.5 | 1.29 |
And I'm still using
our old friend LIMIT. | 3,276.79 | 2.05 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.