Database calculations, sorting and searching
引入本课内容
| English | 释义 | 拼音 |
|---|---|---|
| sort/sɔːt/ | 排序 | pái xù |
| calculated field | 计算字段 | jì suàn zì duàn |
| query/ˈkwɪərɪ/ | 查询 | chá xún |
| calculated control | 计算控件 | jì suàn kòng jiàn |
| ascending/əˈsendɪŋ/ | 升序 | shēng xù |
| descending/dɪˈsendɪŋ/ | 降序 | jiàng xù |
| operator/ˈɒpəreɪtə/ | 运算符 | yùn suàn fú |
| wildcard/ˈwaɪldkɑːd/ | 通配符 | tōng pèi fú |
Ask the database a question
- Databases calculate new values, sort 排序 records and search with queries. The practical exam tests all three.
Calculations
- A calculated field 计算字段 in a query 查询 works out a value per record:
Total: [Price]*[Quantity]. - A calculated control 计算控件 in a report shows a result:
=Sum([Total]). Functions: Sum, Avg, Max, Min, Count.
Which is a calculated field in a query?
难度 1/5 · 今日首次完成可获 100 金币及少量额外奖励
The =Sum(...) form is a calculated control in a report.
Sorting
- Ascending 升序: A→Z, 0→9, oldest first. Descending 降序: the reverse.
- A second criterion orders ties: Surname, then FirstName.
Records are sorted by Surname, then FirstName. When is FirstName used?
难度 1/5 · 今日首次完成可获 100 金币及少量额外奖励
The second criterion breaks ties.
Descending order sorts numbers from 9 to 0.
难度 1/5 · 今日首次完成可获 100 金币及少量额外奖励
Ascending is 0 to 9.
Queries
| operator 运算符 | example |
|---|---|
= <> |
Colour <> "Red" |
> < >= <= |
Price >= 100 |
AND |
Price < 50 AND Stock > 0 |
OR |
Colour = "Red" OR Colour = "Blue" |
NOT |
NOT "London" |
LIKE + wildcards 通配符 |
LIKE "T*"; ? one character |
Red or blue cars under 20 000, newest first: (Colour = "Red" OR Colour = "Blue") AND Price < 20000, sorted by Year descending. Without brackets every red car is selected whatever its price.
Match each criterion to what it finds.
难度 2/5 · 今日首次完成可获 140 金币及少量额外奖励
- means any number of characters.
Which criteria find red or blue cars under 20 000?
难度 1/5 · 今日首次完成可获 100 金币及少量额外奖励
The brackets keep the OR together.
Bracket the OR when mixing with AND. Otherwise AND binds first and the results are wrong.
Calculated fields work per record; calculated controls summarise. Sort ascending or descending with tie-breakers. Queries use comparison operators, AND, OR, NOT and wildcards.
出了什么问题?只有网站团队能看到这些信息。