174|SQL – Super Shelter Shenanigans

BYU Student Author: @Millie_K_B
Reviewers: @Jacob_Dutton, @Andrew_Wilson
Estimated Time to Solve: 20 Minutes

We provide the solution to this challenge using:

  • SQL

Need a program? Click here.

This challenge is correlated with 173|SQL – Shelter Shenanigans and 171|SQL – Shelter Shenanigans Sequel. It is not necessary to complete either challenge before completing this one.

While waiting for a call back from your dream accounting job, you keep your commitment to go forth and serve by volunteering at a local animal shelter. You spent some time cleaning kennels until your boss realized that you’re a tech savvy accountant. She quickly reassigned you to help the receptionists at all three locations answer questions that they receive.

  1. A family came into the Central branch wanting to know which pet has been there the longest; in other words, they want the pet with the earliest impound date.
    a. The query should return that pet’s name, breed, impound date, and adoption fee. Order by impound date and show only the first result.
    b. The family will adopt the pet if the adoption fee is less than $150. Will they adopt the pet?
  2. A young girl called wanting to adopt an adult cat. She is willing to travel to any of the three locations for the cat as long as the cat is up to date on their vaccinations.
    a. The query should return the names, breeds, age in years, vaccination status, and locations of all cats over 2 years old who are fully vaccinated. Order by age in years.
    b. Note: The cat breeds are Domestic Shorthair, Siamese, Scottish Fold, Ragdoll, Bengal, and Maine Co
    c. Which locations, if any, have a fully vaccinated adult cat?
  3. Someone walked into the East location looking for a caretaker named Carter, who had told them about a Great Dane named Cooper who was available for adoption. The receptionist didn’t recognize either of those names and asked you to help direct the client to the correct location.
    a. The query should return the location name, address, city, state, and zip code for the location that Carter the caretaker works at, or that Cooper the Great Dane is housed at.

She provides you with the database, the diagram below explaining the relationship between tables, and a can of Sprite. Good luck!


  1. Import all the sheets of data into whichever program you choose to practice SQL. If you choose to use Microsoft Access, you can use the database file provided and skip step 2, as the relationships have already been created.
  2. Verify that the relationships between the various Excel sheets are correct. If no relationships are identified, create the relationships yourself.
  3. Create queries that will answer the questions above. For your solutions, show the SQL query and the resulting table or record.

Data Files

Suggestions and Hints
  • For the first query, remember to use WHERE to only select animals at the Central location.
  • Using SELECT TOP 1 will give you the first queried result.
  • Pay attention to how you group your WHERE statement for the second query.
  • For the third query, you do not need to join all three tables. Pick whether to join on the Animals table or the Employee table.