Challenge

The full text of this chapter, to read or revisit. To practise, do the exercises.

▶ Do the exercises

Exercise 1 — Battle report: Step 1

Professor Pi is writing the season's battle report and needs three queries from you.

Step 1: return the name, wins, losses and a column form equal to 'Winning' when there are more wins than losses, 'Losing' when there are fewer, and 'Even' otherwise. Sort by name.

Starter code
-- Step 1: the form of each Codémon

Exercise 2 — Battle report: Step 2

Step 2: the report must be readable by everyone, so no NULL may appear.

Write a query that returns: 1. display_name: the nickname when there is one, otherwise the name 2. tier: 'Unknown' when the power is NULL, 'Strong' at 80 or more, 'Medium' at 70 or more, 'Weak' otherwise Sort by display_name.

Starter code
-- Step 2: readable names and tiers

Exercise 3 — Battle report: Step 3

Step 3: the Professor wants the form of the Codémons summarised per type, with the three forms as columns.

Write a query that returns, for each type: 1. the type 2. winning: how many Codémons have more wins than losses 3. losing: how many have fewer wins than losses 4. even: how many have as many wins as losses Sort by type.

Starter code
-- Step 3: one line per type, one column per form
Back to the course