Database calculations, sorting and searching
ВведеноВ этом уроке
| English | Значение |
|---|---|
| sort/sɔːt/ | |
| calculated field | |
| query/ˈkwɪərɪ/ | A request to retrieve or manipulate information, especially data in a database. |
| calculated control | |
| ascending/əˈsendɪŋ/ | |
| descending/dɪˈsendɪŋ/ | |
| operator/ˈɒpəreɪtə/ | Symbols or keywords specifying operations to perform on values or expressions. |
| wildcard/ˈwaɪldkɑːd/ |
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.
Что пошло не так? Это увидит только команда сайта.