text stringlengths 1 81 | start float64 0 10.1k | duration float64 0 24.9 |
|---|---|---|
let's try this one called Tyll. | 2,585.93 | 2.79 |
Well, maybe I want to just find the
titles that have a Y or an I in here, | 2,588.72 | 5.04 |
but I also don't know if it's one
L or maybe two L's, for instance. | 2,593.76 | 3.933 |
Let me go back and try this. | 2,597.693 | 1.167 |
I'll say SELECT, let's say, "title" FROM
"longlist" WHERE my "title" is LIKE-- | 2,598.86 | 8.07 |
I know it begins with a T. I
don't know if this is a Y or an I. | 2,606.93 | 4.56 |
And maybe I know that it has maybe
one or two characters after it. | 2,611.49 | 4.62 |
So I'll try this one. | 2,616.11 | 1.5 |
Now I have three underscores,
single underscore. | 2,617.61 | 3.21 |
So match any book title that
has T and then any three | 2,620.82 | 4.38 |
individual characters after it. | 2,625.2 | 1.8 |
I'll hit Enter. | 2,627 | 1.29 |
And I'll see I get back Tyll. | 2,628.29 | 2.01 |
This is the only title that has T
and then three characters after it. | 2,630.3 | 5.7 |
I could try to get better with this. | 2,636 | 1.69 |
I could say maybe I'll accept
five or six characters like that. | 2,637.69 | 3.29 |
Hit Enter. | 2,640.98 | 1.05 |
And I'll see-- whoops, I
didn't compute my query here. | 2,642.03 | 2.467 |
Let me just try it from the top again. | 2,644.497 | 1.583 |
I'll say SELECT "title"
from "longlist" where | 2,646.08 | 2.79 |
title is like, let's say,
T-Y underscore, underscore, | 2,648.87 | 3.9 |
underscore, underscore. | 2,652.77 | 1.2 |
Hit Semicolon. | 2,653.97 | 2.82 |
And now I get no matches. | 2,656.79 | 1.46 |
So there is no book in
the database that has T-Y | 2,658.25 | 3.84 |
and then, let's say, three or four
underscores for any character after it. | 2,662.09 | 6.05 |
OK. | 2,668.14 | 0.69 |
So this covers our
use of LIKE, but let's | 2,668.83 | 4.08 |
keep going and building
more complex conditions | 2,672.91 | 2.22 |
to find even more answers to questions
we have about this data over here. | 2,675.13 | 5.31 |
Let me think what we should show next. | 2,680.44 | 3.09 |
We've seen LIKE. | 2,683.53 | 1.26 |
We've seen some compound conditionals. | 2,684.79 | 2.07 |
Well, let's go back to trying to find
books that are in a certain year. | 2,686.86 | 4.53 |
So we saw earlier we
had this kind of query. | 2,691.39 | 3.15 |
We could say SELECT "title" and "year"
FROM, let's say, our "longlist." | 2,694.54 | 6.27 |
Now I can try to find those books
that are written or nominated | 2,700.81 | 3.57 |
in 2022 and 2023. | 2,704.38 | 2.61 |
But let's say I want to go further. | 2,706.99 | 1.89 |
I want those from 2019 to 2022,
a span of multiple years here. | 2,708.88 | 6.25 |
So I could try it like
this, WHERE "year" equals-- | 2,715.13 | 3.86 |
let's go ahead and say 2019-- | 2,718.99 | 2.31 |
OR "year" is 2020 OR "year" is 2021. | 2,721.3 | 6.86 |
And let me make a new line again. | 2,728.16 | 2.22 |
OR "year" is 2022 Semicolon. | 2,730.38 | 5.81 |
And before I run this query,
let me ask our audience, | 2,736.19 | 3.75 |
what strikes you as being not very
well designed about this query? | 2,739.94 | 4.97 |
What could I be doing better here? | 2,744.91 | 2.65 |
So I'm seeing maybe one improvement
is that I don't need to write out | 2,747.56 | 5.09 |
OR "year" is this, OR "year" is that. | 2,752.65 | 3.3 |
I could probably do better with this. | 2,755.95 | 1.95 |
And let's introduce some
new keywords for working | 2,757.9 | 2.73 |
with ranges in terms of our conditions. | 2,760.63 | 3.61 |
So here, we can see some
new operators to use. | 2,764.24 | 4.22 |
We have this greater than
sign, this less than sign, | 2,768.46 | 3.99 |
greater than or equal to,
and less than or equal to. | 2,772.45 | 2.91 |
And we can use these to build
ranges inside of our queries to say, | 2,775.36 | 4.44 |
I want something to be greater than this
number or less than this number too. | 2,779.8 | 4.83 |
And we can combine these
with AND and our OR | 2,784.63 | 2.55 |
we saw before to get back in
this case some set of rows | 2,787.18 | 4.26 |
that match what we intend to find. | 2,791.44 | 2.79 |
So let me go back and
try some of these out. | 2,794.23 | 2.22 |
I'll try to improve the
design of this query. | 2,796.45 | 3.39 |
Let me first run it, and we'll
see we do get back 2019 to 2022. | 2,799.84 | 6.51 |
But I could probably do better. | 2,806.35 | 1.63 |
So let's try using
our new operators here | 2,807.98 | 2.78 |
that can give us some
range capabilities. | 2,810.76 | 2.61 |
I'll say SELECT "title" and also
SELECT "year" from "longlist." | 2,813.37 | 6.42 |
But now I want those rows where the
year is greater than or equal to 2019, | 2,819.79 | 7.29 |
and the year is less than
or equal to 2022 Semicolon. | 2,827.08 | 6.3 |
I'll hit Enter. | 2,833.38 | 1.57 |
Notice I'll get the very same results. | 2,834.95 | 2.16 |
So I get all those same rows. | 2,837.11 | 1.91 |
But now my query is much smaller. | 2,839.02 | 2.68 |
It's making use of these range
operators I've seen so far. | 2,841.7 | 4.64 |
I could even further improve this. | 2,846.34 | 2.59 |
I could make this a
little better designed to. | 2,848.93 | 2.45 |
Let me go back to some slides and
show you we could use these keywords | 2,851.38 | 3.21 |
BETWEEN blank AND blank, where
this can be some condition | 2,854.59 | 4.92 |
or some number in this case. | 2,859.51 | 1.72 |
I could say between,
let's say, 2019 AND 2022. | 2,861.23 | 5.09 |
This is inclusive. | 2,866.32 | 1.42 |
So if I say 2019 AND 2022, I'll get back
a query that includes 2019 and 2022. | 2,867.74 | 8.54 |
So let me try this one. | 2,876.28 | 1.62 |
I'll go back over here. | 2,877.9 | 1.23 |
And I will now try
SELECT "title" and "year" | 2,879.13 | 5.04 |
from "longlist," WHERE the
"year" is between 2019 AND 2022. | 2,884.17 | 8.2 |
Same results now, which is a different
way of writing this same query. | 2,892.37 | 5.62 |
Now what else can we
do with these ranges? | 2,897.99 | 3.13 |
Well, as we've said before, these books
actually have some ratings involved. | 2,901.12 | 5.36 |
These ratings are
crowdsourced from Goodreads, | 2,906.48 | 2.55 |
a site you can review books online. | 2,909.03 | 2.37 |
And I want to find maybe the books
that have a rating of 4.0 or higher. | 2,911.4 | 4.17 |
Well, I could do that now with my ranges
I could say SELECT "title" and "rating" | 2,915.57 | 5.7 |
from my "longlist." | 2,921.27 | 1.74 |
And I could say WHERE the "rating"
is greater than 4.0 Semicolon. | 2,923.01 | 5.91 |
I'll hit Enter. | 2,928.92 | 1.02 |
And I'll see now only those
books that have a rating of 4.0 | 2,929.94 | 5.16 |
or higher like this. | 2,935.1 | 3.56 |
I could even combine conditions. | 2,938.66 | 2.31 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.