CREATE TABLE Breeds (
    breed_code TEXT PRIMARY KEY,
    breed_name TEXT
);
CREATE TABLE Charges (
    charge_id NUMBER PRIMARY KEY,
    charge_type TEXT,
    charge_amount NUMBER
);
CREATE TABLE Sizes (
    size_code TEXT PRIMARY KEY,
    size_description TEXT
);
CREATE TABLE Treatment_Types (
    treatment_type_code TEXT PRIMARY KEY,
    treatment_type_description TEXT
);
CREATE TABLE Owners (
    owner_id NUMBER PRIMARY KEY,
    first_name TEXT,
    last_name TEXT,
    street TEXT,
    city TEXT,
    state TEXT,
    zip_code TEXT,
    email_address TEXT,
    home_phone TEXT,
    cell_number TEXT
);
CREATE TABLE Dogs (
    dog_id NUMBER PRIMARY KEY,
    owner_id NUMBER,
    abandoned_yn TEXT,
    breed_code TEXT,
    size_code TEXT,
    name TEXT,
    age TEXT,
    date_of_birth TIME,
    gender TEXT,
    weight TEXT,
    date_arrived TIME,
    date_adopted TIME,
    date_departed TIME,
    FOREIGN KEY ("owner_id") REFERENCES Owners("owner_id"),
    FOREIGN KEY ("owner_id") REFERENCES Owners("owner_id"),
    FOREIGN KEY ("size_code") REFERENCES Sizes("size_code"),
    FOREIGN KEY ("breed_code") REFERENCES Breeds("breed_code")
);
CREATE TABLE Professionals (
    professional_id NUMBER PRIMARY KEY,
    role_code TEXT,
    first_name TEXT,
    street TEXT,
    city TEXT,
    state TEXT,
    zip_code TEXT,
    last_name TEXT,
    email_address TEXT,
    home_phone TEXT,
    cell_number TEXT
);
CREATE TABLE Treatments (
    treatment_id NUMBER PRIMARY KEY,
    dog_id NUMBER,
    professional_id NUMBER,
    treatment_type_code TEXT,
    date_of_treatment TIME,
    cost_of_treatment NUMBER,
    FOREIGN KEY ("dog_id") REFERENCES Dogs("dog_id"),
    FOREIGN KEY ("professional_id") REFERENCES Professionals("professional_id"),
    FOREIGN KEY ("treatment_type_code") REFERENCES Treatment_Types("treatment_type_code")
);

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: Find the owner id and zip code of the owner who spent the most money in total for his or her dogs.
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: Find the id and cell phone of the professionals who operate two or more types of treatments.
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: Which professionals have operated a treatment that costs less than the average? Give me theor first names and last names.
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 date of each treatment, together with the first name of the professional who operated it.
SQL: SELECT T1.date_of_treatment ,  T2.first_name FROM Treatments AS T1 JOIN Professionals AS T2 ON T1.professional_id  =  T2.professional_id

Question: What are the date and the operating professional's first name of each treatment?
SQL: SELECT T1.date_of_treatment ,  T2.first_name FROM Treatments AS T1 JOIN Professionals AS T2 ON T1.professional_id  =  T2.professional_id

Question: List the cost of each treatment and the corresponding treatment type description.
SQL: SELECT T1.cost_of_treatment ,  T2.treatment_type_description FROM Treatments AS T1 JOIN treatment_types AS T2 ON T1.treatment_type_code  =  T2.treatment_type_code

Question: What are the cost and treatment type description of each treatment?
SQL: SELECT T1.cost_of_treatment ,  T2.treatment_type_description FROM Treatments AS T1 JOIN treatment_types AS T2 ON T1.treatment_type_code  =  T2.treatment_type_code

Question: List each owner's first name, last name, and the size of his for her dog.
SQL: SELECT T1.first_name ,  T1.last_name ,  T2.size_code FROM Owners AS T1 JOIN Dogs AS T2 ON T1.owner_id  =  T2.owner_id

Question: What are each owner's first name, last name, and the size of their dog?
SQL: SELECT T1.first_name ,  T1.last_name ,  T2.size_code FROM Owners AS T1 JOIN Dogs AS T2 ON T1.owner_id  =  T2.owner_id

Question: List pairs of the owner's first name and the dogs's name.
SQL: SELECT T1.first_name ,  T2.name FROM Owners AS T1 JOIN Dogs AS T2 ON T1.owner_id  =  T2.owner_id

Question: What are each owner's first name and their dogs's name?
SQL: SELECT T1.first_name ,  T2.name FROM Owners AS T1 JOIN Dogs AS T2 ON T1.owner_id  =  T2.owner_id

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 of the rarest breed? Show their names and treatment dates.
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: Find the first names of owners living in Virginia and the names of dogs they own.
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: What are the arriving date and the departing date of the dogs who have gone through a treatment?
SQL: SELECT DISTINCT T1.date_arrived ,  T1.date_departed FROM Dogs AS T1 JOIN Treatments AS T2 ON T1.dog_id  =  T2.dog_id

Question: Find the arriving date and the departing date of the dogs that received a treatment.
SQL: SELECT DISTINCT T1.date_arrived ,  T1.date_departed FROM Dogs AS T1 JOIN Treatments AS T2 ON T1.dog_id  =  T2.dog_id

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 max(age) FROM Dogs )

Question: Who owns the youngest dog? Give me his or her last name.
SQL: SELECT T1.last_name FROM Owners AS T1 JOIN Dogs AS T2 ON T1.owner_id  =  T2.owner_id WHERE T2.age  =  ( SELECT max(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: What are the emails of the professionals living in either the state of Hawaii or the state of Wisconsin?
SQL: SELECT email_address FROM Professionals WHERE state  =  'Hawaii' OR state  =  'Wisconsin'

Question: What are the arriving date and the departing date of all the dogs?
SQL: SELECT date_arrived ,  date_departed FROM Dogs