Skip to content

Instantly share code, notes, and snippets.

@koskimas
Last active November 14, 2021 14:41
Show Gist options
  • Select an option

  • Save koskimas/6d10075e2c48adb554dce6afa07a1d52 to your computer and use it in GitHub Desktop.

Select an option

Save koskimas/6d10075e2c48adb554dce6afa07a1d52 to your computer and use it in GitHub Desktop.
with "species_ages" as (
select "species",
min("pet"."age") as "min_age",
max("pet"."age") as "max_age"
from "pet"
group by "species"
)
select "max_age"
from "species_ages", (
select "species", count("toy"."id") as "num_toys"
from "pet"
inner join "toy" on "toy"."pet_id" = "pet"."id"
group by "species"
) as "species_toy_counts"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment