The vet is mailing check-up reminders for older pets in Oslo. Look only at pets whose owner's city is 'Oslo', sort by age from oldest, and keep the first 2. Pick three columns: the pet's name, the owner's name, and age.
The tables
owners
id
name
city
phone
1
Lena
Oslo
555-0101
2
Marco
Rome
NULL
3
Priya
Oslo
555-0103
4
Omar
Cairo
NULL
5
Sofia
Rome
555-0105
5 rows
pets
id
name
kind
age
weight
owner_id
1
Biscuit
dog
3
12
1
2
Mochi
cat
5
4
1
3
Pepper
dog
8
20
2
4
Nemo
fish
1
NULL
3
5
Luna
cat
2
3
3
6
Rex
dog
11
30
NULL
7
Kiwi
bird
4
NULL
5
8
Tofu
cat
7
5
NULL
8 rows
owners
id
name
city
phone
1
Lena
Oslo
555-0101
2
Marco
Rome
NULL
3
Priya
Oslo
555-0103
4
Omar
Cairo
NULL
5
Sofia
Rome
555-0105
5 rows
pets
id
name
kind
age
weight
owner_id
1
Biscuit
dog
3
12
1
2
Mochi
cat
5
4
1
3
Pepper
dog
8
20
2
4
Nemo
fish
1
NULL
3
5
Luna
cat
2
3
3
6
Rex
dog
11
30
NULL
7
Kiwi
bird
4
NULL
5
8
Tofu
cat
7
5
NULL
8 rows
query.sql
SELECT pets.name, owners.name, pets.age
FROM pets
JOIN owners ON pets.owner_id = owners.id
-- your code here: WHERE to keep Oslo, sort by pets.age from high to low, LIMIT 2
;
Ctrl + Enter runs too
Result
Run shows what your query gives. When it looks right, Submit.