column_names: -1
*
0
breed code
0
breed name
1
charge id
1
charge type
1
charge amount
2
size code
2
size description
3
treatment type code
3
treatment type description
4
owner id
4
first name
4
last name
4
street
4
city
4
state
4
zip code
4
email address
4
home phone
4
cell number
5
dog id
5
owner id
5
abandoned yes or no
5
breed code
5
size code
5
name
5
age
5
date of birth
5
gender
5
weight
5
date arrived
5
date adopted
5
date departed
6
professional id
6
role code
6
first name
6
street
6
city
6
state
6
zip code
6
last name
6
email address
6
home phone
6
cell number
7
treatment id
7
dog id
7
professional id
7
treatment type code
7
date of treatment
7
cost of treatment
column_names_original: -1
*
0
breed_code
0
breed_name
1
charge_id
1
charge_type
1
charge_amount
2
size_code
2
size_description
3
treatment_type_code
3
treatment_type_description
4
owner_id
4
first_name
4
last_name
4
street
4
city
4
state
4
zip_code
4
email_address
4
home_phone
4
cell_number
5
dog_id
5
owner_id
5
abandoned_yn
5
breed_code
5
size_code
5
name
5
age
5
date_of_birth
5
gender
5
weight
5
date_arrived
5
date_adopted
5
date_departed
6
professional_id
6
role_code
6
first_name
6
street
6
city
6
state
6
zip_code
6
last_name
6
email_address
6
home_phone
6
cell_number
7
treatment_id
7
dog_id
7
professional_id
7
treatment_type_code
7
date_of_treatment
7
cost_of_treatment
column_types: text
text
text
number
text
number
text
text
text
text
number
text
text
text
text
text
text
text
text
text
number
number
text
text
text
text
text
time
text
text
time
time
time
number
text
text
text
text
text
text
text
text
text
text
number
number
number
text
time
number
db_id: dog_kennels
table_names: breeds
charges
sizes
treatment types
owners
dogs
professionals
treatments
table_names_original: Breeds
Charges
Sizes
Treatment_Types
Owners
Dogs
Professionals
Treatments

Which states have both owners and professionals living there?
SELECT state FROM Owners INTERSECT SELECT state FROM Professionals

Find the states where both owners and professionals live.
SELECT state FROM Owners INTERSECT SELECT state FROM Professionals

What is the average age of the dogs who have gone through any treatments?
SELECT avg(age) FROM Dogs WHERE dog_id IN ( SELECT dog_id FROM Treatments )

Find the average age of the dogs who went through treatments.
SELECT avg(age) FROM Dogs WHERE dog_id IN ( SELECT dog_id FROM Treatments )

Which professionals live in the state of Indiana or have done treatment on more than 2 treatments? List his or her id, last name and cell phone.
SELECT professional_id ,  last_name ,  cell_number FROM Professionals WHERE state  =  'Indiana' UNION SELECT T1.professional_id ,  T1.last_name ,  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

Find the id, last name and cell phone of the professionals who live in the state of Indiana or have performed more than two treatments.
SELECT professional_id ,  last_name ,  cell_number FROM Professionals WHERE state  =  'Indiana' UNION SELECT T1.professional_id ,  T1.last_name ,  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

Which dogs have not cost their owner more than 1000 for treatment ? List the dog names .
select name from dogs where dog_id not in ( select dog_id from treatments group by dog_id having sum(cost_of_treatment)  >  1000 )

What are the names of the dogs for which the owner has not spend more than 1000 for treatment ?
select name from dogs where dog_id not in ( select dog_id from treatments group by dog_id having sum(cost_of_treatment)  >  1000 )

Which first names are used for professionals or owners but are not used as dog names?
SELECT first_name FROM Professionals UNION SELECT first_name FROM Owners EXCEPT SELECT name FROM Dogs

Find the first names that are used for professionals or owners but are not used as dog names.
SELECT first_name FROM Professionals UNION SELECT first_name FROM Owners EXCEPT SELECT name FROM Dogs

Which professional did not operate any treatment on dogs? List the professional's id, role and email.
SELECT professional_id ,  role_code ,  email_address FROM Professionals EXCEPT SELECT T1.professional_id ,  T1.role_code ,  T1.email_address FROM Professionals AS T1 JOIN Treatments AS T2 ON T1.professional_id  =  T2.professional_id

Give me the id, role and email of the professionals who did not perform any treatment on dogs.
SELECT professional_id ,  role_code ,  email_address FROM Professionals EXCEPT SELECT T1.professional_id ,  T1.role_code ,  T1.email_address FROM Professionals AS T1 JOIN Treatments AS T2 ON T1.professional_id  =  T2.professional_id

Which owner owns the most dogs? List the owner id, first name and last name.
SELECT T1.owner_id ,  T2.first_name ,  T2.last_name FROM Dogs AS T1 JOIN Owners AS T2 ON T1.owner_id  =  T2.owner_id GROUP BY T1.owner_id ORDER BY count(*) DESC LIMIT 1

Return the owner id, first name and last name of the owner who has the most dogs.
SELECT T1.owner_id ,  T2.first_name ,  T2.last_name FROM Dogs AS T1 JOIN Owners AS T2 ON T1.owner_id  =  T2.owner_id GROUP BY T1.owner_id ORDER BY count(*) DESC LIMIT 1

Which professionals have done at least two treatments? List the professional's id, role, and first name.
SELECT T1.professional_id ,  T1.role_code ,  T1.first_name FROM Professionals AS T1 JOIN Treatments AS T2 ON T1.professional_id  =  T2.professional_id GROUP BY T1.professional_id HAVING count(*)  >=  2

What are the id, role, and first name of the professionals who have performed two or more treatments?
SELECT T1.professional_id ,  T1.role_code ,  T1.first_name FROM Professionals AS T1 JOIN Treatments AS T2 ON T1.professional_id  =  T2.professional_id GROUP BY T1.professional_id HAVING count(*)  >=  2

What is the name of the breed with the most dogs?
SELECT T1.breed_name FROM Breeds AS T1 JOIN Dogs AS T2 ON T1.breed_code  =  T2.breed_code GROUP BY T1.breed_name ORDER BY count(*) DESC LIMIT 1

Which breed do the most dogs have? Give me the breed name.
SELECT T1.breed_name FROM Breeds AS T1 JOIN Dogs AS T2 ON T1.breed_code  =  T2.breed_code GROUP BY T1.breed_name ORDER BY count(*) DESC LIMIT 1

Which owner has paid for the most treatments on his or her dogs? List the owner id and last name.
SELECT T1.owner_id ,  T1.last_name 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 count(*) DESC LIMIT 1

Tell me the owner id and last name of the owner who spent the most on treatments of his or her dogs.
SELECT T1.owner_id ,  T1.last_name 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 count(*) DESC LIMIT 1

What is the description of the treatment type that costs the least money in total?
SELECT T1.treatment_type_description FROM Treatment_types AS T1 JOIN Treatments AS T2 ON T1.treatment_type_code  =  T2.treatment_type_code GROUP BY T1.treatment_type_code ORDER BY sum(cost_of_treatment) ASC LIMIT 1

Give me the description of the treatment type whose total cost is the lowest.
SELECT T1.treatment_type_description FROM Treatment_types AS T1 JOIN Treatments AS T2 ON T1.treatment_type_code  =  T2.treatment_type_code GROUP BY T1.treatment_type_code ORDER BY sum(cost_of_treatment) ASC LIMIT 1

Which owner has paid the largest amount of money in total for their dogs? Show the owner id and zip code.
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

Find the owner id and zip code of the owner who spent the most money in total for his or her dogs.
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

Which professionals have done at least two types of treatments? List the professional id and cell phone.
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

Find the id and cell phone of the professionals who operate two or more types of treatments.
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

What are the first name and last name of the professionals who have done treatment with cost below average?
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 )

Which professionals have operated a treatment that costs less than the average? Give me theor first names and last names.
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 )

List the date of each treatment, together with the first name of the professional who operated it.
SELECT T1.date_of_treatment ,  T2.first_name FROM Treatments AS T1 JOIN Professionals AS T2 ON T1.professional_id  =  T2.professional_id

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

List the cost of each treatment and the corresponding treatment type description.
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

What are the cost and treatment type description of each treatment?
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

List each owner's first name, last name, and the size of his for her dog.
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

What are each owner's first name, last name, and the size of their dog?
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

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

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

List the names of the dogs of the rarest breed and the treatment dates of them.
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 )

Which dogs are of the rarest breed? Show their names and treatment dates.
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 )

Which dogs are owned by someone who lives in Virginia? List the owner's first name and the dog's name.
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'

Find the first names of owners living in Virginia and the names of dogs they own.
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'

What are the arriving date and the departing date of the dogs who have gone through a treatment?
SELECT DISTINCT T1.date_arrived ,  T1.date_departed FROM Dogs AS T1 JOIN Treatments AS T2 ON T1.dog_id  =  T2.dog_id

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

List the last name of the owner owning the youngest dog.
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 )

Who owns the youngest dog? Give me his or her last name.
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 )

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

What are the emails of the professionals living in either the state of Hawaii or the state of Wisconsin?
SELECT email_address FROM Professionals WHERE state  =  'Hawaii' OR state  =  'Wisconsin'

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

List the arrival date and the departure date for all the dogs.
SELECT date_arrived ,  date_departed FROM Dogs

How many dogs went through any treatments?
SELECT count(DISTINCT dog_id) FROM Treatments

Count the number of dogs that went through a treatment.
SELECT count(DISTINCT dog_id) FROM Treatments

How many professionals have performed any treatment to dogs?
SELECT count(DISTINCT professional_id) FROM Treatments

Find the number of professionals who have ever treated dogs.
SELECT count(DISTINCT professional_id) FROM Treatments

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

Find the role, street, city and state of the professionals living in a city that contains the substring 'West'.
SELECT role_code ,  street ,  city ,  state FROM professionals WHERE city LIKE '%West%'

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

Return the first name, last name and email of the owners living in a state whose name contains the substring 'North'.
SELECT first_name ,  last_name ,  email_address FROM Owners WHERE state LIKE '%North%'

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

Count the number of dogs of an age below the average.
SELECT count(*) FROM Dogs WHERE age  <  ( SELECT avg(age) FROM Dogs )

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

Show me the cost of the most recently performed treatment.
SELECT cost_of_treatment FROM Treatments ORDER BY date_of_treatment DESC LIMIT 1

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

Tell me the number of dogs that have not received any treatment .
select count(*) from dogs where dog_id not in ( select dog_id from treatments )

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

Find the number of owners who do not own any dogs at this moment.
SELECT count(*) FROM Owners WHERE owner_id NOT IN ( SELECT owner_id FROM Dogs )

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

Find the number of professionals who have not treated any dogs.
SELECT count(*) FROM Professionals WHERE professional_id NOT IN ( SELECT professional_id FROM Treatments )

List the dog name, age and weight of the dogs who have been abandoned? 1 stands for yes, and 0 stands for no.
SELECT name ,  age ,  weight FROM Dogs WHERE abandoned_yn  =  1

What are the dog name, age and weight of the dogs that were abandoned? Note that 1 stands for yes, and 0 stands for no in the tables.
SELECT name ,  age ,  weight FROM Dogs WHERE abandoned_yn  =  1

What is the average age of all the dogs?
SELECT avg(age) FROM Dogs

Compute the average age of all the dogs.
SELECT avg(age) FROM Dogs

What is the age of the oldest dog?
SELECT max(age) FROM Dogs

Tell me the age of the oldest dog.
SELECT max(age) FROM Dogs

How much does each charge type costs? List both charge type and amount.
SELECT charge_type ,  charge_amount FROM Charges

List each charge type and its amount.
SELECT charge_type ,  charge_amount FROM Charges

How much does the most expensive charge type costs?
SELECT max(charge_amount) FROM Charges

What is the charge amount of the most expensive charge type?
SELECT max(charge_amount) FROM Charges

List the email, cell phone and home phone of all the professionals.
SELECT email_address ,  cell_number ,  home_phone FROM professionals

What are the email, cell phone and home phone of each professional?
SELECT email_address ,  cell_number ,  home_phone FROM professionals

What are all the possible breed type and size type combinations?
SELECT DISTINCT breed_code ,  size_code FROM dogs

Find the distinct breed type and size type combinations for dogs.
SELECT DISTINCT breed_code ,  size_code FROM dogs

List the first name of all the professionals along with the description of the treatment they have done.
SELECT DISTINCT T1.first_name ,  T3.treatment_type_description FROM professionals AS T1 JOIN Treatments AS T2 ON T1.professional_id  =  T2.professional_id JOIN Treatment_types AS T3 ON T2.treatment_type_code  =  T3.treatment_type_code

What are each professional's first name and description of the treatment they have performed?
SELECT DISTINCT T1.first_name ,  T3.treatment_type_description FROM professionals AS T1 JOIN Treatments AS T2 ON T1.professional_id  =  T2.professional_id JOIN Treatment_types AS T3 ON T2.treatment_type_code  =  T3.treatment_type_code