Database: dog_kennels

Question: Which owner has paid the largest amount of money in total for their dogs? Show the owner id and zip code.
SQL: SELECT T1.owner_id ,  T1.zip_code FROM Owners AS T1 JOIN Dogs AS T2 ON T1.owner_id  =  T2.owner_id JOIN Treatments AS T3 ON T2.dog_id  =  T3.dog_id GROUP BY T1.owner_id ORDER BY sum(T3.cost_of_treatment) DESC LIMIT 1

Question: Which professionals have done at least two types of treatments? List the professional id and cell phone.
SQL: SELECT T1.professional_id ,  T1.cell_number FROM Professionals AS T1 JOIN Treatments AS T2 ON T1.professional_id  =  T2.professional_id GROUP BY T1.professional_id HAVING count(*)  >=  2

Question: What are the first name and last name of the professionals who have done treatment with cost below average?
SQL: SELECT DISTINCT T1.first_name ,  T1.last_name FROM Professionals AS T1 JOIN Treatments AS T2 WHERE cost_of_treatment  <  ( SELECT avg(cost_of_treatment) FROM Treatments )

Question: List the names of the dogs of the rarest breed and the treatment dates of them.
SQL: SELECT T1.name ,  T2.date_of_treatment FROM Dogs AS T1 JOIN Treatments AS T2 ON T1.dog_id  =  T2.dog_id WHERE T1.breed_code  =  ( SELECT breed_code FROM Dogs GROUP BY breed_code ORDER BY count(*) ASC LIMIT 1 )

Question: Which dogs are owned by someone who lives in Virginia? List the owner's first name and the dog's name.
SQL: SELECT T1.first_name ,  T2.name FROM Owners AS T1 JOIN Dogs AS T2 ON T1.owner_id  =  T2.owner_id WHERE T1.state  =  'Virginia'

Question: List the last name of the owner owning the youngest dog.
SQL: SELECT T1.last_name FROM Owners AS T1 JOIN Dogs AS T2 ON T1.owner_id  =  T2.owner_id WHERE T2.age  =  ( SELECT min(age) FROM Dogs )

Question: List the emails of the professionals who live in the state of Hawaii or the state of Wisconsin.
SQL: SELECT email_address FROM Professionals WHERE state  =  'Hawaii' OR state  =  'Wisconsin'

Question: Which professionals live in a city containing the substring 'West'? List his or her role, street, city and state.
SQL: SELECT role_code ,  street ,  city ,  state FROM professionals WHERE city LIKE '%West%'

Question: Which owners live in the state whose name contains the substring 'North'? List his first name, last name and email.
SQL: SELECT first_name ,  last_name ,  email_address FROM Owners WHERE state LIKE '%North%'

Question: How many dogs have an age below the average?
SQL: SELECT count(*) FROM Dogs WHERE age  <  ( SELECT avg(age) FROM Dogs )

Question: How much does the most recent treatment cost?
SQL: SELECT cost_of_treatment FROM Treatments ORDER BY date_of_treatment DESC LIMIT 1

Question: How many dogs have not gone through any treatment?
SQL: SELECT count(*) FROM Dogs WHERE dog_id NOT IN ( SELECT dog_id FROM Treatments )

Question: How many owners temporarily do not have any dogs?
SQL: SELECT count(*) FROM Owners WHERE owner_id NOT IN ( SELECT owner_id FROM Dogs )

Question: How many professionals did not operate any treatment on dogs?
SQL: SELECT count(*) FROM Professionals WHERE professional_id NOT IN ( SELECT professional_id FROM Treatments )