Class 10 Computer Science — Asking a database a question
Read a query as three separate decisions — which fields, which records, in what order — and work out how much comes back.
Name: ________________________
1.A table of pupils has six fields. How many columns does the answer to this query have?
SELECT name, marks FROM pupils WHERE marks > 60
2.A query gives back six records and orders them by mark, largest first. The six marks are 44, 91, 67, 91, 30 and 55. What is the mark in the third row of the answer?
3.The answer to a query comes back as twelve rows of four columns. How many single values are in that answer?
4.What does the WHERE part of a query decide?
- a) Which records come back
- b) The order the records come back in
- c) Which fields come back
- d) Which table is looked in
5.A query orders its answer by mark, largest first, and where two records hold the same mark, by roll number, smallest first. Three records come back: roll 7 with mark 91, roll 3 with mark 91, and roll 9 with mark 60. Which roll number is in the top row?
6.A table holds forty records. Twenty-five have a mark over 60, thirty are in the swimming team, and twenty are both. How many records satisfy "mark over 60 OR in the swimming team"?
7.Sort each piece of a query by what it decides about the answer.
Groups: Decides which records come back · Decides which fields come back
- WHERE marks > 60
- WHERE marks < 40
- SELECT roll
- SELECT name, house, marks
- SELECT name, marks
- WHERE house = 'red'
8.A table holds seven records whose marks are 12, 48, 65, 90, 33, 71 and 55. Put these conditions in order of how many rows a query using each one gives back, fewest first.
- WHERE marks > 60
- WHERE marks > 70
- WHERE marks > 40
- WHERE marks > 85
Answer key — Class 10 Computer Science — Asking a database a question
- 1. 2
- 2. 67
- 3. 48
- 4. a) Which records come back
- 5. 3
- 6. 35
- 7. WHERE marks > 60 → Decides which records come back; SELECT name, marks → Decides which fields come back; WHERE house = 'red' → Decides which records come back; SELECT roll → Decides which fields come back; WHERE marks < 40 → Decides which records come back; SELECT name, house, marks → Decides which fields come back
- 8. 1. WHERE marks > 85 2. WHERE marks > 70 3. WHERE marks > 60 4. WHERE marks > 40