Subqueries lab exercise Use subqueries to answer these queries. The row with the youngest pet. SELECT * FROM pet WHERE birth=(SELECT Max(birth) FROM pet); The row with the youngest cat. SELECT * FROM pet WHERE birth=(SELECT Max(birth) FROM pet WHERE species='cat'); The row(s) with pets older than the average (i.e. median) pet age. SELECT * FROM pet WHERE birth<(SELECT Median(birth) FROM pet); Non-subquery: what is the median birth date? Which pet's birth is it? SELECT Median(birth) FROM pet; SELECT * FROM pet WHERE birth=(SELECT Median(birth) FROM pet); The pets older than Claws. SELECT * FROM pet WHERE birth<(SELECT birth FROM pet WHERE name='Claws'); The pets older than Claws in increasing age order. SELECT * FROM pet WHERE birth<(SELECT birth FROM pet WHERE name='Claws') ORDER BY birth DESC; The living pets older than Claws in increasing age order. SELECT * FROM pet WHERE birth<(SELECT birth FROM pet WHERE name='Claws') AND death IS NULL ORDER BY birth DESC; The name, birth and age in years of the living pets older than Claws in increasing age order. hint: Sysdate SELECT name,birth,(Sysdate-birth)/365 FROM pet WHERE birth<(SELECT birth FROM pet WHERE name='Claws') AND death IS NULL ORDER BY birth DESC; The pets whose individual weights are more than 25% of the total weight of all the pets: SELECT * FROM pet WHERE weight>.25*(SELECT Sum(weight) FROM pet); The pets older than the earliest event. SELECT * FROM pet WHERE birth<(SELECT Min(eventdate) FROM event); Owners whose pets have had a lobotomy. SELECT owner FROM pet WHERE name IN (SELECT name FROM event WHERE type='lobotomy');