1.Easy
An INNER JOIN returns:
- AOnly rows with matching values in both tables
- BAll rows from the left table, with NULLs where there is no match
- CAll rows from both tables
- DRows that do not match
2.Easy
How do you sort a result from the highest to the lowest salary?
- ASORT salary DOWN
- BORDER BY salary ASC
- CORDER BY salary DESC
- DGROUP BY salary DESC
3.Easy
How does UNION ALL differ from UNION?
- AUNION ALL keeps duplicate rows
- BUNION ALL only works on one table
- CUNION ALL sorts the result
- DUNION ALL removes duplicate rows
4.Medium
Second normal form (2NF) removes:
- AAll NULL values
- BForeign keys
- CTransitive dependencies between non-key columns via another non-key column
- DPartial dependencies of non-key columns on part of a composite key
5.Medium
Which query returns the number of different cities in the customers table?
- ASELECT COUNT(city) FROM customers GROUP BY city
- BSELECT SUM(DISTINCT city) FROM customers
- CSELECT COUNT(DISTINCT city) FROM customers
- DSELECT DISTINCT COUNT(city) FROM customers
6.Medium
A column holds the values 10, 20 and NULL. What does AVG(col) return?
- ANULL
- B30
- C10
- D15
7.Hard
What is the result of SELECT COUNT(col) FROM t if all values in col are NULL and the table has 10 rows?
- ANULL
- BAn error
- C10
- D0
8.Hard
When is decomposing R into R1 and R2 guaranteed to be lossless?
- AWhen R1 and R2 have the same number of columns
- BWhen R1 and R2 have no attributes in common
- CWhen the common attributes of R1 and R2 form a superkey of R1 or of R2
- DWhen every attribute of R appears in both R1 and R2
Answer key
- 1. A · Only rows with matching values in both tables
- 2. C · ORDER BY salary DESC
- 3. A · UNION ALL keeps duplicate rows
- 4. D · Partial dependencies of non-key columns on part of a composite key
- 5. C · SELECT COUNT(DISTINCT city) FROM customers
- 6. D · 15
- 7. D · 0
- 8. C · When the common attributes of R1 and R2 form a superkey of R1 or of R2
Full step-by-step solutions: practise this topic on examproblems.com.