跟讀練習: Learn Basic SQL in 15 Minutes | Business Intelligence For Beginners | SQL Tutorial For Beginners 1/3 - 通過影片學習英語口語
選擇練習模式
每種模式都會開啟全屏練習室。
201 句
如果句子過短或過長,請點選 Edit 進行調整。
1
In this video, you're going to learn the basics of SQL querying in just 15 minutes.
2
And by the time we're finished, you'll be wondering what all the fuss was about.
3
Are you ready?
4
Then let's get started.
5
Hello and welcome to Vitamin BI, bringing you business intelligence for beginners and beyond.
6
On this channel I help you do more with data, so if you're new here consider subscribing.
7
Right, so as I said in my intro I'm going to teach you the basics of SQL querying,
8
the essentials that you'll need to know if you're considering becoming a business intelligence analyst.
9
Obviously we can only go so far in 15 minutes, but I promise you
10
that by the time we're finished
11
you'll be able to understand quite a lot of what you might be called upon to do.
12
We'll be focusing specifically on querying data, not creating or deleting databases,
13
tables or data, just selecting data from tables that we want to return for our specific needs.
14
Before we get started, let me give you a little context.
15
You might be wondering why you need to learn SQL with BI tools becoming more and more sophisticated.
16
Can't they write the SQL queries for me the answer to
17
that is yes and no yes
18
when it comes to requesting data for different charts graphs and tables
19
that you might want to present in dashboards in these cases
20
the bi tool will have some kind of graphical interface to be able to drag
21
and drop fields to return data but no in
22
that in a lot of cases you'll need to write sql queries to pre -aggregate filter
23
and select only the data necessary for the project that you're working on.
24
These are often called views and you create views mainly
25
because it's more efficient than connecting to all data when you only need some of it.
26
So you could have a table that contains millions of rows of data
27
but by creating a view of it your BI tool will
28
only need to work with a few thousand making analysis and presenting results much faster.
29
So you see, knowing how to query with SQL is a useful skill to have.
30
Let's jump onto my computer and get started.
31
So today we're working with a SQLite database that I found online, containing data compiled from the FIFA video game by EA Sports.
32
So soccer stats.
33
I'll leave a link to the database in the description if you want to play around with it too.
34
In terms of the tool I'm using to query the database?
35
It's called NaviCat.
36
It's the premium version that allows you to connect to and query pretty much any relational database.
37
But they also have a version for specific RDBMS like MySQL, SQL Server, etc. Link also in the description.
38
Here we're in the NaviCat interface.
39
On the left we can see that I'm connected to the SoccerDB connection
40
that I've created and in that connection is a database called main and in that database we have various tables country,
41
league, match, player etc. We're going to be working mainly with the player table.
42
If I double click it we'll see the data contained within that table.
43
We've got three different IDs, player name, birthday, height and weight.
44
What I want to do is write SQL queries
45
and ask the database to return specific data from this table so I'll open a new query window.
46
Now when we're asking for data we're using what's called a select statement
47
so that's what we need to write first and
48
if we want to return the whole table in the result we do so with a star.
49
Then we specify the table that we want to select everything from.
50
In this case the table called player select star from player then we run the query
51
and the database returns all data from that table you may notice
52
that i've written everything in lowercase
53
because the sequel isn't case sensitive however i have the option to what's called beautify the sequel
54
and when i do you'll notice that select
55
and from have been capitalized although it's not obligatory this does actually make your queries easier to read.
56
It's not so important with such a small query like this one
57
but when you've got one with tens if not hundreds of lines of code it really does make life easier.
58
So we've selected all fields or columns and all rows from the table
59
but what if we only want to select specific fields?
60
Simple.
61
Instead of the star we just write out the field names
62
we want separated by commas like this player underscore name comma birthday I run this,
63
and those are the fields returned.
64
When we select specific fields, we can also rename them by creating aliases.
65
To do this, we use the as function.
66
So player name as name.
67
And we can see that update.
68
We could specify an alias containing a space, but to do this, we would need to put the name in quotes like this.
69
Full name.
70
Let's go back to all data
71
and look now at how we can ask the database to only return specific rows in the result.
72
To do this we use a WHERE clause with different operators.
73
For example, we could select only players with a weight of 190 pounds.
74
So we use the equals operator.
75
We could also select any player with a weight greater than 190 pounds or greater than or equal to 190.
76
You see, it's not that complicated.
77
And we've gone from over 11 ,000 records to just under 1 ,000 being returned.
78
We can also specify more than one condition by using either
79
and or or so weight greater than 190 and height greater than 190
80
so both conditions must be met if I change it to
81
or it means that either condition must be met in order for the row to be returned
82
so that's selecting rows based on the value in integer fields what about when it comes to text values?
83
Well, we can also use the equals operator to find any row where the text matches exactly with what we specify.
84
PlayerName equals Aaron Galindo.
85
But we could also use the like operator which achieves the same goal.
86
But what if we want to select just rows from all players called Aaron?
87
So basically the player name field starts with Aaron.
88
Here we can use a percent character after the text to look for, like so.
89
And we get all Arons returned.
90
If we wanted to find any player name that ends with Aaron, we put the percent character before.
91
Nothing that ends with Aaron.
92
We could put a percent before and after, which would basically mean any player name that contains Aaron.
93
And we've got Rolando Arons.
94
Finally, here's an example which puts the percent in the middle of text.
95
So here we'll return all rows where the player name starts with a and ends with n.
96
you can go even further with the like operator by using
97
underscore to represent single characters an example would be like t underscore m percent
98
so the underscore is asking for any rows where the player name starts with t
99
then any character between the t and the m followed by anything and run.
100
We've got Tamas, Tamir, Tim, Timmy, etc.
101
There are also things called wildcards that allow you to go even further
102
when specifying the rows you want to return but we won't go into those for this video.
103
We will however finish looking at the where clause by talking about a couple more operators that you can use.
104
For text fields we have in which allows us to specify multiple or statements, more simply.
105
However, it can only be used for exact matches, so we can't use percents or underscores with it.
106
So let's look for Ronaldo and Messi.
107
Open brackets Cristiano Ronaldo, Lionel Messi.
108
For integers, we can use the between operator.
109
So I could say wear weight between 180 and 190.
110
Finally we have the isNull and isNotNull.
111
Null being empty.
112
In this table we don't have any null values.
113
But if I open up the match table we can see that there are lots in there.
114
So select star from match where home player 1 is null. or is not null.
115
There we go.
116
Let's go back to our player table and see how we can sort results.
117
We can do this using the ORDER BY clause.
118
The rows are currently sorted by the ID field in ascending order.
119
But if we wanted to sort by weight, we can say ORDER BY WAIT.
120
This sorts by weight in ascending order, because that's the default sorting method when not explicitly specified.
121
But we can change this to descending order by adding DESC now we can see who the heaviest player is
122
when it comes to sorting data using order by this isn't something that's overly important for our use case
123
because when we're selecting data to create views we're usually then going to connect
124
that view to a bi tool and use
125
that for building individual chart queries
126
and these tools will let you apply sorts to the data
127
now we're going to look at how to join data from different tables.
128
To demonstrate this I'm going to use the player attributes table.
129
We can see that in this table we have the player ID but not the player name.
130
To be able to create a view containing the player name plus the overall rating
131
we would need to join the data from the player attributes and player tables.
132
I'm going to start by specifying player API ID comma date comma overall rating.
133
Now I want to get the player name from the player table.
134
How do I do that?
135
Well because we're going to need fields from two different tables we need to specify which field comes from which table.
136
We do this by writing the table name dot field name.
137
So player attributes dot player API ID.
138
Same for date and overall rating.
139
Now we can specify, perhaps after the player ID, player dot player name.
140
If I run this I'll get an error saying
141
that there's no such column as player .playerName because we're saying that we're looking for it in the player attributes table.
142
This is when we need to specify the joining of the tables using one of the four join types.
143
I'm not going to go into them in this video
144
but I'll probably do a separate video that explains them in more detail so don't forget to subscribe.
145
So in this case we'll use an inner join
146
and we'll say inner join player the player table on
147
and now we specify what fields
148
we want to use to create the join in this case we're going to use the player api id field
149
which is contained in both tables
150
and again we have to add the table name first dot field name equals player dot player API ID and run.
151
Now we have the player name appended to the player attributes table data.
152
Pretty clever right?
153
But let me show you something even more clever.
154
I showed you earlier how to use the as function to create aliases for fields.
155
Well we can actually do this for tables as well which makes the query much cleaner.
156
First I'm going to give the player attributes table an alias of a and the player table an alias of b.
157
I just need to write these two letters after where I've specified each table.
158
So a after player attributes here and b after player here.
159
Once I do this I can now replace the table name for each field like this.
160
You see, much cleaner.
161
So, you may notice that there are multiple rows for each player on different dates.
162
So how would we add up all of these different values for each player?
163
Well, to do this, we're going to want to aggregate the data using the SUM aggregator.
164
I'll add this to the overall rating field and run the query.
165
Ah, that's not what we were expecting.
166
But that's because we haven't specified in the query how we want to group the data together.
167
This is when we need to use the GROUP BY clause.
168
When we use the GROUP BY clause we need to add into it all of the fields that we need to group.
169
So in this case essentially all fields apart from the overall rating.
170
A .PlayerApiId, B .Playername, A .Date And run
171
This is correct, but not exactly what we want.
172
We want to combine all of the ratings for the different dates,
173
so we actually want to remove the date field from the specified fields as well as the group by. and run.
174
That's better.
175
But let's clean it up by aliasing the sum overall rating as rating.
176
Let's sort this descending.
177
Order by rating descending.
178
Strange that Ronaldo and Messi aren't in there at the top.
179
Let's try and see why this is.
180
Perhaps there are just more entries for some players when we sum them up.
181
To find this out, we could add a count of b .playerName.
182
And yes, in this case how about using an average?
183
I'll replace sum with average, avg, and run.
184
And there we go, that makes more sense.
185
We're going to go one step further and filter this result.
186
To do that we can use the HAVING clause.
187
The HAVING clause is only applied to the result of the GROUP BY function, so isn't the same as the WHERE keyword that's applied before.
188
And it's only applied to numeric values, so in this case I'm going to ask for only ratings above 85.
189
I need to write it directly after the group by and before the order by.
190
So having rating greater than 85 and run.
191
Only 26 records.
192
And there we have our final query.
193
I'll beautify it and this is what it should look like.
194
You can see that all of the SQL keywords are capitalised.
195
And you can see that we've come a fairly long way in a very short space of time.
196
We've only covered a very small part of SQL as a whole, so there's masses more to learn.
197
But what I've shown you today is a really good foundation for giving you the confidence to dive deeper.
198
Did I not say that once we'd finished, you'd wonder what all the fuss was about?
199
If you got value out of this video, please do like, share
200
and subscribe for more videos like this one why not start with this playlist here as always thanks for watching
201
I've been Adam Feiner and until the next time stay BI curious
FOR YOU
推薦影片
本課的詞彙與口語要點
這節口語課以影片“Learn Basic SQL in 15 Minutes”為素材。 影片中反覆出現的詞有:player, table, field, row, select。 這段影片共有 201 個句子、2466 個單詞可供跟讀。 講話部分時長為 17:28。 說話人語速平穩,每分鐘約 141 個詞,很適合跟讀。 84% 的單詞屬於英語最常用的 3,000 詞,其餘的詞建議在練習前先學一下。
影片中的重點詞彙
影片中 15 個值得學習的單詞,附發音和釋義:
| 單詞 | 發音 | 釋義 |
|---|---|---|
| query 名詞 | /ˈkwɪɹ.i/ | 問題 /問題, 質問 /質問 |
| select 動詞 | /sɪˈlɛkt/ | 選 /選, 挑選 /挑選 |
| database 名詞 | /ˈdeɪtəˌbeɪs/ | 資料庫 /資料庫 |
| rat 名詞 | /ɹæt/ | лочў, 鳥鼠 /鳥鼠 |
| operator 名詞 | /ˈɑpəˌɹeɪtɚ/ | 話務員 /話務員, 接線員 /接線員 |
| clause 名詞 | /klɔːz/ | 分句 |
| attribute 名詞 | /ˈæt.ɹɪˌbjut/ | 屬性 /屬性 |
| connect 動詞 | /kəˈnɛkt/ | 連線 /連線 |
| null 名詞 | /nʌl/ | 空值 |
| subscribe 動詞 | /səbˈskɹaɪb/ | 簽署 /簽署 |
| chart 名詞 | /t͡ʃɑɹt/ | 圖表 /圖表 |
| rating 名詞 | /ˈɹeɪtɪŋ/ | 評級 /評級, 分級 /分級 |
| filter 名詞 | /ˈfɪltɚ/ | 過濾器 /過濾器, 濾過器 /濾過器 |
| interface 名詞 | /ˈɪn(t)ɚˌfeɪs/ | 介面 |
| sequel 名詞 | /ˈsiːkwəl/ | 續集 /續集 |
值得反覆跟讀的句子
影片中簡短而完整的句子,可以直接用在日常對話裡:
- Let's jump onto my computer and get started.
- In terms of the tool I'm using to query the database?
- You see, it's not that complicated.
- In this table we don't have any null values.
- How do I do that?
影片中的語法
說話人最常用的結構,並附上影片中的原話:
| 結構 | 影片中的用法 |
|---|---|
| 條件句 if + 從句,will/would + 動詞 — 條件及其結果 | If I double click it we'll see · If I run this I'll get |
| 現在完成時 have/has + 過去分詞 — 過去發生但與現在仍有關聯的事 | I've created · i've written · have been capitalized |
| 被動語態 be + 過去分詞 — 強調發生了什麼,而不是誰做的 | might be called · are often called · have been capitalized |
| 用 “might / may” 表可能 might/may + 動詞 — 有可能但不確定的事 | might be · might want · may notice |
需要注意的發音
說話人用了 70 次縮略和弱讀形式,例如 we're, I'm, I'll。請按聽到的簡短形式來說。
- “sh” 和 “zh” 音: efficient /ɪˈfɪʃənt/, essentially /ɪˈsɛnʃəli/, dashboard /ˈdæʃˌboɹd/
- 長單詞——注意重音位置: operator /ˈɑpəˌɹeɪtɚ/, complicated /ˈkɑm.plɪˌkeɪ.tɪd/, essentially /ɪˈsɛnʃəli/, aggregator /ˈæɡɹɪˌɡeɪtɚ/, capitalize /ˈkæpətəˌlaɪz/
中文母語者容易讀錯的音:
- /v/ — 不要讀成 /w/,上齒輕觸下唇: clever /ˈklɛv.ɚ/, sensitive /ˈsɛn.sɪt.ɪv/, dive /daɪv/
- 詞尾子音 — 要讀清楚,後面不要加母音: select /sɪˈlɛkt/, database /ˈdeɪtəˌbeɪs/, rat /ɹæt/, clause /klɔːz/, attribute /ˈæt.ɹɪˌbjut/
- /r/ 和 /l/ 的區別: graphical /ˈɡɹæfɪkəl/, obligatory /əˈblɪɡ.ə.tɔ.ɹi/
如何用這段影片練習
- 先完整聽一遍影片,不要開口,記下不認識的單詞。
- 用正常速度逐句跟讀,每句重複到你的節奏與說話人一致為止。
- 錄下自己的聲音並與原聲對比,特別注意 query, select, database 這類單詞。
什麼是跟讀法?
跟讀法 (Shadowing) 是一種有科學依據的語言學習技巧,最初開發用於專業口譯員的培訓,並由多語言者Alexander Arguelles博士普及。這個方法簡單而強大:您在聽英語母語原聲的同時立即大聲重複——就像是一個延遲1-2秒緊跟說話者的影子。與被動聽力或語法練習不同,跟讀法強迫您的大腦和口腔肌肉同時處理並模模擬實的講話模式。研究表明它能顯著提高發音準確性,語調,節奏,連讀,聽力理解和口語流利度——使其成為雅思口語備考和真實英語交流最有效的方法之一。












