Input:
[INST] Here is a database schema:
classroom :
building [ TEXT ] primary_key
room_number [ TEXT ]
capacity [ INT ]

department :
dept_name [ TEXT ] primary_key
building [ TEXT ]
budget [ INT ]

course :
course_id [ TEXT ] primary_key
title [ TEXT ]
dept_name [ TEXT ] course.dept_name = department.dept_name
credits [ INT ]

instructor :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] instructor.dept_name = department.dept_name
salary [ INT ]

section :
course_id [ TEXT ] primary_key section.course_id = course.course_id
sec_id [ TEXT ]
semester [ TEXT ]
year [ INT ]
building [ TEXT ] section.building = classroom.building
room_number [ TEXT ] section.room_number = classroom.room_number
time_slot_id [ TEXT ]

teaches :
ID [ TEXT ] primary_key teaches.ID = instructor.ID
course_id [ TEXT ] teaches.course_id = section.course_id
sec_id [ TEXT ] teaches.sec_id = section.sec_id
semester [ TEXT ] teaches.semester = section.semester
year [ INT ] teaches.year = section.year

student :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] student.dept_name = department.dept_name
tot_cred [ INT ]

takes :
ID [ TEXT ] primary_key takes.ID = student.ID
course_id [ TEXT ] takes.course_id = section.course_id
sec_id [ TEXT ] takes.sec_id = section.sec_id
semester [ TEXT ] takes.semester = section.semester
year [ INT ] takes.year = section.year
grade [ TEXT ]

advisor :
s_ID [ TEXT ] primary_key advisor.s_ID = student.ID
i_ID [ TEXT ] advisor.i_ID = instructor.ID

time_slot :
time_slot_id [ TEXT ] primary_key
day [ TEXT ]
start_hr [ INT ]
start_min [ INT ]
end_hr [ INT ]
end_min [ INT ]

prereq :
course_id [ TEXT ] primary_key prereq.course_id = course.course_id
prereq_id [ TEXT ] prereq.prereq_id = course.course_id

Please write me a SQL statement that answers the following question: Find the name of the courses that do not have any prerequisite? [/INST]

Output: SELECT title FROM course WHERE course_id NOT IN (SELECT course_id FROM prereq);


Input:
[INST] Here is a database schema:
classroom :
building [ TEXT ] primary_key
room_number [ TEXT ]
capacity [ INT ]

department :
dept_name [ TEXT ] primary_key
building [ TEXT ]
budget [ INT ]

course :
course_id [ TEXT ] primary_key
title [ TEXT ]
dept_name [ TEXT ] course.dept_name = department.dept_name
credits [ INT ]

instructor :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] instructor.dept_name = department.dept_name
salary [ INT ]

section :
course_id [ TEXT ] primary_key section.course_id = course.course_id
sec_id [ TEXT ]
semester [ TEXT ]
year [ INT ]
building [ TEXT ] section.building = classroom.building
room_number [ TEXT ] section.room_number = classroom.room_number
time_slot_id [ TEXT ]

teaches :
ID [ TEXT ] primary_key teaches.ID = instructor.ID
course_id [ TEXT ] teaches.course_id = section.course_id
sec_id [ TEXT ] teaches.sec_id = section.sec_id
semester [ TEXT ] teaches.semester = section.semester
year [ INT ] teaches.year = section.year

student :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] student.dept_name = department.dept_name
tot_cred [ INT ]

takes :
ID [ TEXT ] primary_key takes.ID = student.ID
course_id [ TEXT ] takes.course_id = section.course_id
sec_id [ TEXT ] takes.sec_id = section.sec_id
semester [ TEXT ] takes.semester = section.semester
year [ INT ] takes.year = section.year
grade [ TEXT ]

advisor :
s_ID [ TEXT ] primary_key advisor.s_ID = student.ID
i_ID [ TEXT ] advisor.i_ID = instructor.ID

time_slot :
time_slot_id [ TEXT ] primary_key
day [ TEXT ]
start_hr [ INT ]
start_min [ INT ]
end_hr [ INT ]
end_min [ INT ]

prereq :
course_id [ TEXT ] primary_key prereq.course_id = course.course_id
prereq_id [ TEXT ] prereq.prereq_id = course.course_id

Please write me a SQL statement that answers the following question: What are the titles of courses without prerequisites? [/INST]

Output: SELECT title FROM course WHERE course_id NOT IN (SELECT course_id FROM prereq);


Input:
[INST] Here is a database schema:
classroom :
building [ TEXT ] primary_key
room_number [ TEXT ]
capacity [ INT ]

department :
dept_name [ TEXT ] primary_key
building [ TEXT ]
budget [ INT ]

course :
course_id [ TEXT ] primary_key
title [ TEXT ]
dept_name [ TEXT ] course.dept_name = department.dept_name
credits [ INT ]

instructor :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] instructor.dept_name = department.dept_name
salary [ INT ]

section :
course_id [ TEXT ] primary_key section.course_id = course.course_id
sec_id [ TEXT ]
semester [ TEXT ]
year [ INT ]
building [ TEXT ] section.building = classroom.building
room_number [ TEXT ] section.room_number = classroom.room_number
time_slot_id [ TEXT ]

teaches :
ID [ TEXT ] primary_key teaches.ID = instructor.ID
course_id [ TEXT ] teaches.course_id = section.course_id
sec_id [ TEXT ] teaches.sec_id = section.sec_id
semester [ TEXT ] teaches.semester = section.semester
year [ INT ] teaches.year = section.year

student :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] student.dept_name = department.dept_name
tot_cred [ INT ]

takes :
ID [ TEXT ] primary_key takes.ID = student.ID
course_id [ TEXT ] takes.course_id = section.course_id
sec_id [ TEXT ] takes.sec_id = section.sec_id
semester [ TEXT ] takes.semester = section.semester
year [ INT ] takes.year = section.year
grade [ TEXT ]

advisor :
s_ID [ TEXT ] primary_key advisor.s_ID = student.ID
i_ID [ TEXT ] advisor.i_ID = instructor.ID

time_slot :
time_slot_id [ TEXT ] primary_key
day [ TEXT ]
start_hr [ INT ]
start_min [ INT ]
end_hr [ INT ]
end_min [ INT ]

prereq :
course_id [ TEXT ] primary_key prereq.course_id = course.course_id
prereq_id [ TEXT ] prereq.prereq_id = course.course_id

Please write me a SQL statement that answers the following question: How many different instructors have taught some course? [/INST]

Output: SELECT COUNT (DISTINCT id) FROM teaches;


Input:
[INST] Here is a database schema:
classroom :
building [ TEXT ] primary_key
room_number [ TEXT ]
capacity [ INT ]

department :
dept_name [ TEXT ] primary_key
building [ TEXT ]
budget [ INT ]

course :
course_id [ TEXT ] primary_key
title [ TEXT ]
dept_name [ TEXT ] course.dept_name = department.dept_name
credits [ INT ]

instructor :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] instructor.dept_name = department.dept_name
salary [ INT ]

section :
course_id [ TEXT ] primary_key section.course_id = course.course_id
sec_id [ TEXT ]
semester [ TEXT ]
year [ INT ]
building [ TEXT ] section.building = classroom.building
room_number [ TEXT ] section.room_number = classroom.room_number
time_slot_id [ TEXT ]

teaches :
ID [ TEXT ] primary_key teaches.ID = instructor.ID
course_id [ TEXT ] teaches.course_id = section.course_id
sec_id [ TEXT ] teaches.sec_id = section.sec_id
semester [ TEXT ] teaches.semester = section.semester
year [ INT ] teaches.year = section.year

student :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] student.dept_name = department.dept_name
tot_cred [ INT ]

takes :
ID [ TEXT ] primary_key takes.ID = student.ID
course_id [ TEXT ] takes.course_id = section.course_id
sec_id [ TEXT ] takes.sec_id = section.sec_id
semester [ TEXT ] takes.semester = section.semester
year [ INT ] takes.year = section.year
grade [ TEXT ]

advisor :
s_ID [ TEXT ] primary_key advisor.s_ID = student.ID
i_ID [ TEXT ] advisor.i_ID = instructor.ID

time_slot :
time_slot_id [ TEXT ] primary_key
day [ TEXT ]
start_hr [ INT ]
start_min [ INT ]
end_hr [ INT ]
end_min [ INT ]

prereq :
course_id [ TEXT ] primary_key prereq.course_id = course.course_id
prereq_id [ TEXT ] prereq.prereq_id = course.course_id

Please write me a SQL statement that answers the following question: Count the number of distinct instructors who have taught a course. [/INST]

Output: SELECT COUNT (DISTINCT id) FROM teaches;


Input:
[INST] Here is a database schema:
classroom :
building [ TEXT ] primary_key
room_number [ TEXT ]
capacity [ INT ]

department :
dept_name [ TEXT ] primary_key
building [ TEXT ]
budget [ INT ]

course :
course_id [ TEXT ] primary_key
title [ TEXT ]
dept_name [ TEXT ] course.dept_name = department.dept_name
credits [ INT ]

instructor :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] instructor.dept_name = department.dept_name
salary [ INT ]

section :
course_id [ TEXT ] primary_key section.course_id = course.course_id
sec_id [ TEXT ]
semester [ TEXT ]
year [ INT ]
building [ TEXT ] section.building = classroom.building
room_number [ TEXT ] section.room_number = classroom.room_number
time_slot_id [ TEXT ]

teaches :
ID [ TEXT ] primary_key teaches.ID = instructor.ID
course_id [ TEXT ] teaches.course_id = section.course_id
sec_id [ TEXT ] teaches.sec_id = section.sec_id
semester [ TEXT ] teaches.semester = section.semester
year [ INT ] teaches.year = section.year

student :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] student.dept_name = department.dept_name
tot_cred [ INT ]

takes :
ID [ TEXT ] primary_key takes.ID = student.ID
course_id [ TEXT ] takes.course_id = section.course_id
sec_id [ TEXT ] takes.sec_id = section.sec_id
semester [ TEXT ] takes.semester = section.semester
year [ INT ] takes.year = section.year
grade [ TEXT ]

advisor :
s_ID [ TEXT ] primary_key advisor.s_ID = student.ID
i_ID [ TEXT ] advisor.i_ID = instructor.ID

time_slot :
time_slot_id [ TEXT ] primary_key
day [ TEXT ]
start_hr [ INT ]
start_min [ INT ]
end_hr [ INT ]
end_min [ INT ]

prereq :
course_id [ TEXT ] primary_key prereq.course_id = course.course_id
prereq_id [ TEXT ] prereq.prereq_id = course.course_id

Please write me a SQL statement that answers the following question: Find the total budgets of the Marketing or Finance department. [/INST]

Output: SELECT sum(budget) FROM department WHERE dept_name  =  'Marketing' OR dept_name  =  'Finance';


Input:
[INST] Here is a database schema:
classroom :
building [ TEXT ] primary_key
room_number [ TEXT ]
capacity [ INT ]

department :
dept_name [ TEXT ] primary_key
building [ TEXT ]
budget [ INT ]

course :
course_id [ TEXT ] primary_key
title [ TEXT ]
dept_name [ TEXT ] course.dept_name = department.dept_name
credits [ INT ]

instructor :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] instructor.dept_name = department.dept_name
salary [ INT ]

section :
course_id [ TEXT ] primary_key section.course_id = course.course_id
sec_id [ TEXT ]
semester [ TEXT ]
year [ INT ]
building [ TEXT ] section.building = classroom.building
room_number [ TEXT ] section.room_number = classroom.room_number
time_slot_id [ TEXT ]

teaches :
ID [ TEXT ] primary_key teaches.ID = instructor.ID
course_id [ TEXT ] teaches.course_id = section.course_id
sec_id [ TEXT ] teaches.sec_id = section.sec_id
semester [ TEXT ] teaches.semester = section.semester
year [ INT ] teaches.year = section.year

student :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] student.dept_name = department.dept_name
tot_cred [ INT ]

takes :
ID [ TEXT ] primary_key takes.ID = student.ID
course_id [ TEXT ] takes.course_id = section.course_id
sec_id [ TEXT ] takes.sec_id = section.sec_id
semester [ TEXT ] takes.semester = section.semester
year [ INT ] takes.year = section.year
grade [ TEXT ]

advisor :
s_ID [ TEXT ] primary_key advisor.s_ID = student.ID
i_ID [ TEXT ] advisor.i_ID = instructor.ID

time_slot :
time_slot_id [ TEXT ] primary_key
day [ TEXT ]
start_hr [ INT ]
start_min [ INT ]
end_hr [ INT ]
end_min [ INT ]

prereq :
course_id [ TEXT ] primary_key prereq.course_id = course.course_id
prereq_id [ TEXT ] prereq.prereq_id = course.course_id

Please write me a SQL statement that answers the following question: What is the sum of budgets of the Marketing and Finance departments? [/INST]

Output: SELECT sum(budget) FROM department WHERE dept_name  =  'Marketing' OR dept_name  =  'Finance';


Input:
[INST] Here is a database schema:
classroom :
building [ TEXT ] primary_key
room_number [ TEXT ]
capacity [ INT ]

department :
dept_name [ TEXT ] primary_key
building [ TEXT ]
budget [ INT ]

course :
course_id [ TEXT ] primary_key
title [ TEXT ]
dept_name [ TEXT ] course.dept_name = department.dept_name
credits [ INT ]

instructor :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] instructor.dept_name = department.dept_name
salary [ INT ]

section :
course_id [ TEXT ] primary_key section.course_id = course.course_id
sec_id [ TEXT ]
semester [ TEXT ]
year [ INT ]
building [ TEXT ] section.building = classroom.building
room_number [ TEXT ] section.room_number = classroom.room_number
time_slot_id [ TEXT ]

teaches :
ID [ TEXT ] primary_key teaches.ID = instructor.ID
course_id [ TEXT ] teaches.course_id = section.course_id
sec_id [ TEXT ] teaches.sec_id = section.sec_id
semester [ TEXT ] teaches.semester = section.semester
year [ INT ] teaches.year = section.year

student :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] student.dept_name = department.dept_name
tot_cred [ INT ]

takes :
ID [ TEXT ] primary_key takes.ID = student.ID
course_id [ TEXT ] takes.course_id = section.course_id
sec_id [ TEXT ] takes.sec_id = section.sec_id
semester [ TEXT ] takes.semester = section.semester
year [ INT ] takes.year = section.year
grade [ TEXT ]

advisor :
s_ID [ TEXT ] primary_key advisor.s_ID = student.ID
i_ID [ TEXT ] advisor.i_ID = instructor.ID

time_slot :
time_slot_id [ TEXT ] primary_key
day [ TEXT ]
start_hr [ INT ]
start_min [ INT ]
end_hr [ INT ]
end_min [ INT ]

prereq :
course_id [ TEXT ] primary_key prereq.course_id = course.course_id
prereq_id [ TEXT ] prereq.prereq_id = course.course_id

Please write me a SQL statement that answers the following question: Find the department name of the instructor whose name contains 'Soisalon'. [/INST]

Output: SELECT dept_name FROM instructor WHERE name LIKE '%Soisalon%';


Input:
[INST] Here is a database schema:
classroom :
building [ TEXT ] primary_key
room_number [ TEXT ]
capacity [ INT ]

department :
dept_name [ TEXT ] primary_key
building [ TEXT ]
budget [ INT ]

course :
course_id [ TEXT ] primary_key
title [ TEXT ]
dept_name [ TEXT ] course.dept_name = department.dept_name
credits [ INT ]

instructor :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] instructor.dept_name = department.dept_name
salary [ INT ]

section :
course_id [ TEXT ] primary_key section.course_id = course.course_id
sec_id [ TEXT ]
semester [ TEXT ]
year [ INT ]
building [ TEXT ] section.building = classroom.building
room_number [ TEXT ] section.room_number = classroom.room_number
time_slot_id [ TEXT ]

teaches :
ID [ TEXT ] primary_key teaches.ID = instructor.ID
course_id [ TEXT ] teaches.course_id = section.course_id
sec_id [ TEXT ] teaches.sec_id = section.sec_id
semester [ TEXT ] teaches.semester = section.semester
year [ INT ] teaches.year = section.year

student :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] student.dept_name = department.dept_name
tot_cred [ INT ]

takes :
ID [ TEXT ] primary_key takes.ID = student.ID
course_id [ TEXT ] takes.course_id = section.course_id
sec_id [ TEXT ] takes.sec_id = section.sec_id
semester [ TEXT ] takes.semester = section.semester
year [ INT ] takes.year = section.year
grade [ TEXT ]

advisor :
s_ID [ TEXT ] primary_key advisor.s_ID = student.ID
i_ID [ TEXT ] advisor.i_ID = instructor.ID

time_slot :
time_slot_id [ TEXT ] primary_key
day [ TEXT ]
start_hr [ INT ]
start_min [ INT ]
end_hr [ INT ]
end_min [ INT ]

prereq :
course_id [ TEXT ] primary_key prereq.course_id = course.course_id
prereq_id [ TEXT ] prereq.prereq_id = course.course_id

Please write me a SQL statement that answers the following question: What is the name of the department with an instructure who has a name like 'Soisalon'? [/INST]

Output: SELECT dept_name FROM instructor WHERE name LIKE '%Soisalon%';


Input:
[INST] Here is a database schema:
classroom :
building [ TEXT ] primary_key
room_number [ TEXT ]
capacity [ INT ]

department :
dept_name [ TEXT ] primary_key
building [ TEXT ]
budget [ INT ]

course :
course_id [ TEXT ] primary_key
title [ TEXT ]
dept_name [ TEXT ] course.dept_name = department.dept_name
credits [ INT ]

instructor :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] instructor.dept_name = department.dept_name
salary [ INT ]

section :
course_id [ TEXT ] primary_key section.course_id = course.course_id
sec_id [ TEXT ]
semester [ TEXT ]
year [ INT ]
building [ TEXT ] section.building = classroom.building
room_number [ TEXT ] section.room_number = classroom.room_number
time_slot_id [ TEXT ]

teaches :
ID [ TEXT ] primary_key teaches.ID = instructor.ID
course_id [ TEXT ] teaches.course_id = section.course_id
sec_id [ TEXT ] teaches.sec_id = section.sec_id
semester [ TEXT ] teaches.semester = section.semester
year [ INT ] teaches.year = section.year

student :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] student.dept_name = department.dept_name
tot_cred [ INT ]

takes :
ID [ TEXT ] primary_key takes.ID = student.ID
course_id [ TEXT ] takes.course_id = section.course_id
sec_id [ TEXT ] takes.sec_id = section.sec_id
semester [ TEXT ] takes.semester = section.semester
year [ INT ] takes.year = section.year
grade [ TEXT ]

advisor :
s_ID [ TEXT ] primary_key advisor.s_ID = student.ID
i_ID [ TEXT ] advisor.i_ID = instructor.ID

time_slot :
time_slot_id [ TEXT ] primary_key
day [ TEXT ]
start_hr [ INT ]
start_min [ INT ]
end_hr [ INT ]
end_min [ INT ]

prereq :
course_id [ TEXT ] primary_key prereq.course_id = course.course_id
prereq_id [ TEXT ] prereq.prereq_id = course.course_id

Please write me a SQL statement that answers the following question: How many rooms whose capacity is less than 50 does the Lamberton building have? [/INST]

Output: SELECT count(*) FROM classroom WHERE building  =  'Lamberton' AND capacity  <  50;


Input:
[INST] Here is a database schema:
classroom :
building [ TEXT ] primary_key
room_number [ TEXT ]
capacity [ INT ]

department :
dept_name [ TEXT ] primary_key
building [ TEXT ]
budget [ INT ]

course :
course_id [ TEXT ] primary_key
title [ TEXT ]
dept_name [ TEXT ] course.dept_name = department.dept_name
credits [ INT ]

instructor :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] instructor.dept_name = department.dept_name
salary [ INT ]

section :
course_id [ TEXT ] primary_key section.course_id = course.course_id
sec_id [ TEXT ]
semester [ TEXT ]
year [ INT ]
building [ TEXT ] section.building = classroom.building
room_number [ TEXT ] section.room_number = classroom.room_number
time_slot_id [ TEXT ]

teaches :
ID [ TEXT ] primary_key teaches.ID = instructor.ID
course_id [ TEXT ] teaches.course_id = section.course_id
sec_id [ TEXT ] teaches.sec_id = section.sec_id
semester [ TEXT ] teaches.semester = section.semester
year [ INT ] teaches.year = section.year

student :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] student.dept_name = department.dept_name
tot_cred [ INT ]

takes :
ID [ TEXT ] primary_key takes.ID = student.ID
course_id [ TEXT ] takes.course_id = section.course_id
sec_id [ TEXT ] takes.sec_id = section.sec_id
semester [ TEXT ] takes.semester = section.semester
year [ INT ] takes.year = section.year
grade [ TEXT ]

advisor :
s_ID [ TEXT ] primary_key advisor.s_ID = student.ID
i_ID [ TEXT ] advisor.i_ID = instructor.ID

time_slot :
time_slot_id [ TEXT ] primary_key
day [ TEXT ]
start_hr [ INT ]
start_min [ INT ]
end_hr [ INT ]
end_min [ INT ]

prereq :
course_id [ TEXT ] primary_key prereq.course_id = course.course_id
prereq_id [ TEXT ] prereq.prereq_id = course.course_id

Please write me a SQL statement that answers the following question: Count the number of rooms in Lamberton with capacity lower than 50. [/INST]

Output: SELECT count(*) FROM classroom WHERE building  =  'Lamberton' AND capacity  <  50;


Input:
[INST] Here is a database schema:
classroom :
building [ TEXT ] primary_key
room_number [ TEXT ]
capacity [ INT ]

department :
dept_name [ TEXT ] primary_key
building [ TEXT ]
budget [ INT ]

course :
course_id [ TEXT ] primary_key
title [ TEXT ]
dept_name [ TEXT ] course.dept_name = department.dept_name
credits [ INT ]

instructor :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] instructor.dept_name = department.dept_name
salary [ INT ]

section :
course_id [ TEXT ] primary_key section.course_id = course.course_id
sec_id [ TEXT ]
semester [ TEXT ]
year [ INT ]
building [ TEXT ] section.building = classroom.building
room_number [ TEXT ] section.room_number = classroom.room_number
time_slot_id [ TEXT ]

teaches :
ID [ TEXT ] primary_key teaches.ID = instructor.ID
course_id [ TEXT ] teaches.course_id = section.course_id
sec_id [ TEXT ] teaches.sec_id = section.sec_id
semester [ TEXT ] teaches.semester = section.semester
year [ INT ] teaches.year = section.year

student :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] student.dept_name = department.dept_name
tot_cred [ INT ]

takes :
ID [ TEXT ] primary_key takes.ID = student.ID
course_id [ TEXT ] takes.course_id = section.course_id
sec_id [ TEXT ] takes.sec_id = section.sec_id
semester [ TEXT ] takes.semester = section.semester
year [ INT ] takes.year = section.year
grade [ TEXT ]

advisor :
s_ID [ TEXT ] primary_key advisor.s_ID = student.ID
i_ID [ TEXT ] advisor.i_ID = instructor.ID

time_slot :
time_slot_id [ TEXT ] primary_key
day [ TEXT ]
start_hr [ INT ]
start_min [ INT ]
end_hr [ INT ]
end_min [ INT ]

prereq :
course_id [ TEXT ] primary_key prereq.course_id = course.course_id
prereq_id [ TEXT ] prereq.prereq_id = course.course_id

Please write me a SQL statement that answers the following question: Find the name and budget of departments whose budgets are more than the average budget. [/INST]

Output: SELECT dept_name ,  budget FROM department WHERE budget  >  (SELECT avg(budget) FROM department);


Input:
[INST] Here is a database schema:
classroom :
building [ TEXT ] primary_key
room_number [ TEXT ]
capacity [ INT ]

department :
dept_name [ TEXT ] primary_key
building [ TEXT ]
budget [ INT ]

course :
course_id [ TEXT ] primary_key
title [ TEXT ]
dept_name [ TEXT ] course.dept_name = department.dept_name
credits [ INT ]

instructor :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] instructor.dept_name = department.dept_name
salary [ INT ]

section :
course_id [ TEXT ] primary_key section.course_id = course.course_id
sec_id [ TEXT ]
semester [ TEXT ]
year [ INT ]
building [ TEXT ] section.building = classroom.building
room_number [ TEXT ] section.room_number = classroom.room_number
time_slot_id [ TEXT ]

teaches :
ID [ TEXT ] primary_key teaches.ID = instructor.ID
course_id [ TEXT ] teaches.course_id = section.course_id
sec_id [ TEXT ] teaches.sec_id = section.sec_id
semester [ TEXT ] teaches.semester = section.semester
year [ INT ] teaches.year = section.year

student :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] student.dept_name = department.dept_name
tot_cred [ INT ]

takes :
ID [ TEXT ] primary_key takes.ID = student.ID
course_id [ TEXT ] takes.course_id = section.course_id
sec_id [ TEXT ] takes.sec_id = section.sec_id
semester [ TEXT ] takes.semester = section.semester
year [ INT ] takes.year = section.year
grade [ TEXT ]

advisor :
s_ID [ TEXT ] primary_key advisor.s_ID = student.ID
i_ID [ TEXT ] advisor.i_ID = instructor.ID

time_slot :
time_slot_id [ TEXT ] primary_key
day [ TEXT ]
start_hr [ INT ]
start_min [ INT ]
end_hr [ INT ]
end_min [ INT ]

prereq :
course_id [ TEXT ] primary_key prereq.course_id = course.course_id
prereq_id [ TEXT ] prereq.prereq_id = course.course_id

Please write me a SQL statement that answers the following question: What are the names and budgets of departments with budgets greater than the average? [/INST]

Output: SELECT dept_name ,  budget FROM department WHERE budget  >  (SELECT avg(budget) FROM department);


Input:
[INST] Here is a database schema:
classroom :
building [ TEXT ] primary_key
room_number [ TEXT ]
capacity [ INT ]

department :
dept_name [ TEXT ] primary_key
building [ TEXT ]
budget [ INT ]

course :
course_id [ TEXT ] primary_key
title [ TEXT ]
dept_name [ TEXT ] course.dept_name = department.dept_name
credits [ INT ]

instructor :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] instructor.dept_name = department.dept_name
salary [ INT ]

section :
course_id [ TEXT ] primary_key section.course_id = course.course_id
sec_id [ TEXT ]
semester [ TEXT ]
year [ INT ]
building [ TEXT ] section.building = classroom.building
room_number [ TEXT ] section.room_number = classroom.room_number
time_slot_id [ TEXT ]

teaches :
ID [ TEXT ] primary_key teaches.ID = instructor.ID
course_id [ TEXT ] teaches.course_id = section.course_id
sec_id [ TEXT ] teaches.sec_id = section.sec_id
semester [ TEXT ] teaches.semester = section.semester
year [ INT ] teaches.year = section.year

student :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] student.dept_name = department.dept_name
tot_cred [ INT ]

takes :
ID [ TEXT ] primary_key takes.ID = student.ID
course_id [ TEXT ] takes.course_id = section.course_id
sec_id [ TEXT ] takes.sec_id = section.sec_id
semester [ TEXT ] takes.semester = section.semester
year [ INT ] takes.year = section.year
grade [ TEXT ]

advisor :
s_ID [ TEXT ] primary_key advisor.s_ID = student.ID
i_ID [ TEXT ] advisor.i_ID = instructor.ID

time_slot :
time_slot_id [ TEXT ] primary_key
day [ TEXT ]
start_hr [ INT ]
start_min [ INT ]
end_hr [ INT ]
end_min [ INT ]

prereq :
course_id [ TEXT ] primary_key prereq.course_id = course.course_id
prereq_id [ TEXT ] prereq.prereq_id = course.course_id

Please write me a SQL statement that answers the following question: what is the name of the instructor who is in Statistics department and earns the lowest salary? [/INST]

Output: SELECT name FROM instructor WHERE dept_name  =  'Statistics' ORDER BY salary LIMIT 1;


Input:
[INST] Here is a database schema:
classroom :
building [ TEXT ] primary_key
room_number [ TEXT ]
capacity [ INT ]

department :
dept_name [ TEXT ] primary_key
building [ TEXT ]
budget [ INT ]

course :
course_id [ TEXT ] primary_key
title [ TEXT ]
dept_name [ TEXT ] course.dept_name = department.dept_name
credits [ INT ]

instructor :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] instructor.dept_name = department.dept_name
salary [ INT ]

section :
course_id [ TEXT ] primary_key section.course_id = course.course_id
sec_id [ TEXT ]
semester [ TEXT ]
year [ INT ]
building [ TEXT ] section.building = classroom.building
room_number [ TEXT ] section.room_number = classroom.room_number
time_slot_id [ TEXT ]

teaches :
ID [ TEXT ] primary_key teaches.ID = instructor.ID
course_id [ TEXT ] teaches.course_id = section.course_id
sec_id [ TEXT ] teaches.sec_id = section.sec_id
semester [ TEXT ] teaches.semester = section.semester
year [ INT ] teaches.year = section.year

student :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] student.dept_name = department.dept_name
tot_cred [ INT ]

takes :
ID [ TEXT ] primary_key takes.ID = student.ID
course_id [ TEXT ] takes.course_id = section.course_id
sec_id [ TEXT ] takes.sec_id = section.sec_id
semester [ TEXT ] takes.semester = section.semester
year [ INT ] takes.year = section.year
grade [ TEXT ]

advisor :
s_ID [ TEXT ] primary_key advisor.s_ID = student.ID
i_ID [ TEXT ] advisor.i_ID = instructor.ID

time_slot :
time_slot_id [ TEXT ] primary_key
day [ TEXT ]
start_hr [ INT ]
start_min [ INT ]
end_hr [ INT ]
end_min [ INT ]

prereq :
course_id [ TEXT ] primary_key prereq.course_id = course.course_id
prereq_id [ TEXT ] prereq.prereq_id = course.course_id

Please write me a SQL statement that answers the following question: Give the name of the lowest earning instructor in the Statistics department. [/INST]

Output: SELECT name FROM instructor WHERE dept_name  =  'Statistics' ORDER BY salary LIMIT 1;


Input:
[INST] Here is a database schema:
classroom :
building [ TEXT ] primary_key
room_number [ TEXT ]
capacity [ INT ]

department :
dept_name [ TEXT ] primary_key
building [ TEXT ]
budget [ INT ]

course :
course_id [ TEXT ] primary_key
title [ TEXT ]
dept_name [ TEXT ] course.dept_name = department.dept_name
credits [ INT ]

instructor :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] instructor.dept_name = department.dept_name
salary [ INT ]

section :
course_id [ TEXT ] primary_key section.course_id = course.course_id
sec_id [ TEXT ]
semester [ TEXT ]
year [ INT ]
building [ TEXT ] section.building = classroom.building
room_number [ TEXT ] section.room_number = classroom.room_number
time_slot_id [ TEXT ]

teaches :
ID [ TEXT ] primary_key teaches.ID = instructor.ID
course_id [ TEXT ] teaches.course_id = section.course_id
sec_id [ TEXT ] teaches.sec_id = section.sec_id
semester [ TEXT ] teaches.semester = section.semester
year [ INT ] teaches.year = section.year

student :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] student.dept_name = department.dept_name
tot_cred [ INT ]

takes :
ID [ TEXT ] primary_key takes.ID = student.ID
course_id [ TEXT ] takes.course_id = section.course_id
sec_id [ TEXT ] takes.sec_id = section.sec_id
semester [ TEXT ] takes.semester = section.semester
year [ INT ] takes.year = section.year
grade [ TEXT ]

advisor :
s_ID [ TEXT ] primary_key advisor.s_ID = student.ID
i_ID [ TEXT ] advisor.i_ID = instructor.ID

time_slot :
time_slot_id [ TEXT ] primary_key
day [ TEXT ]
start_hr [ INT ]
start_min [ INT ]
end_hr [ INT ]
end_min [ INT ]

prereq :
course_id [ TEXT ] primary_key prereq.course_id = course.course_id
prereq_id [ TEXT ] prereq.prereq_id = course.course_id

Please write me a SQL statement that answers the following question: Find the title of course that is provided by both Statistics and Psychology departments. [/INST]

Output: SELECT title FROM course WHERE dept_name  =  'Statistics' INTERSECT SELECT title FROM course WHERE dept_name  =  'Psychology';


Input:
[INST] Here is a database schema:
classroom :
building [ TEXT ] primary_key
room_number [ TEXT ]
capacity [ INT ]

department :
dept_name [ TEXT ] primary_key
building [ TEXT ]
budget [ INT ]

course :
course_id [ TEXT ] primary_key
title [ TEXT ]
dept_name [ TEXT ] course.dept_name = department.dept_name
credits [ INT ]

instructor :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] instructor.dept_name = department.dept_name
salary [ INT ]

section :
course_id [ TEXT ] primary_key section.course_id = course.course_id
sec_id [ TEXT ]
semester [ TEXT ]
year [ INT ]
building [ TEXT ] section.building = classroom.building
room_number [ TEXT ] section.room_number = classroom.room_number
time_slot_id [ TEXT ]

teaches :
ID [ TEXT ] primary_key teaches.ID = instructor.ID
course_id [ TEXT ] teaches.course_id = section.course_id
sec_id [ TEXT ] teaches.sec_id = section.sec_id
semester [ TEXT ] teaches.semester = section.semester
year [ INT ] teaches.year = section.year

student :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] student.dept_name = department.dept_name
tot_cred [ INT ]

takes :
ID [ TEXT ] primary_key takes.ID = student.ID
course_id [ TEXT ] takes.course_id = section.course_id
sec_id [ TEXT ] takes.sec_id = section.sec_id
semester [ TEXT ] takes.semester = section.semester
year [ INT ] takes.year = section.year
grade [ TEXT ]

advisor :
s_ID [ TEXT ] primary_key advisor.s_ID = student.ID
i_ID [ TEXT ] advisor.i_ID = instructor.ID

time_slot :
time_slot_id [ TEXT ] primary_key
day [ TEXT ]
start_hr [ INT ]
start_min [ INT ]
end_hr [ INT ]
end_min [ INT ]

prereq :
course_id [ TEXT ] primary_key prereq.course_id = course.course_id
prereq_id [ TEXT ] prereq.prereq_id = course.course_id

Please write me a SQL statement that answers the following question: What is the title of a course that is listed in both the Statistics and Psychology departments? [/INST]

Output: SELECT title FROM course WHERE dept_name  =  'Statistics' INTERSECT SELECT title FROM course WHERE dept_name  =  'Psychology';


Input:
[INST] Here is a database schema:
classroom :
building [ TEXT ] primary_key
room_number [ TEXT ]
capacity [ INT ]

department :
dept_name [ TEXT ] primary_key
building [ TEXT ]
budget [ INT ]

course :
course_id [ TEXT ] primary_key
title [ TEXT ]
dept_name [ TEXT ] course.dept_name = department.dept_name
credits [ INT ]

instructor :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] instructor.dept_name = department.dept_name
salary [ INT ]

section :
course_id [ TEXT ] primary_key section.course_id = course.course_id
sec_id [ TEXT ]
semester [ TEXT ]
year [ INT ]
building [ TEXT ] section.building = classroom.building
room_number [ TEXT ] section.room_number = classroom.room_number
time_slot_id [ TEXT ]

teaches :
ID [ TEXT ] primary_key teaches.ID = instructor.ID
course_id [ TEXT ] teaches.course_id = section.course_id
sec_id [ TEXT ] teaches.sec_id = section.sec_id
semester [ TEXT ] teaches.semester = section.semester
year [ INT ] teaches.year = section.year

student :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] student.dept_name = department.dept_name
tot_cred [ INT ]

takes :
ID [ TEXT ] primary_key takes.ID = student.ID
course_id [ TEXT ] takes.course_id = section.course_id
sec_id [ TEXT ] takes.sec_id = section.sec_id
semester [ TEXT ] takes.semester = section.semester
year [ INT ] takes.year = section.year
grade [ TEXT ]

advisor :
s_ID [ TEXT ] primary_key advisor.s_ID = student.ID
i_ID [ TEXT ] advisor.i_ID = instructor.ID

time_slot :
time_slot_id [ TEXT ] primary_key
day [ TEXT ]
start_hr [ INT ]
start_min [ INT ]
end_hr [ INT ]
end_min [ INT ]

prereq :
course_id [ TEXT ] primary_key prereq.course_id = course.course_id
prereq_id [ TEXT ] prereq.prereq_id = course.course_id

Please write me a SQL statement that answers the following question: Find the title of course that is provided by Statistics but not Psychology departments. [/INST]

Output: SELECT title FROM course WHERE dept_name  =  'Statistics' EXCEPT SELECT title FROM course WHERE dept_name  =  'Psychology';


Input:
[INST] Here is a database schema:
classroom :
building [ TEXT ] primary_key
room_number [ TEXT ]
capacity [ INT ]

department :
dept_name [ TEXT ] primary_key
building [ TEXT ]
budget [ INT ]

course :
course_id [ TEXT ] primary_key
title [ TEXT ]
dept_name [ TEXT ] course.dept_name = department.dept_name
credits [ INT ]

instructor :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] instructor.dept_name = department.dept_name
salary [ INT ]

section :
course_id [ TEXT ] primary_key section.course_id = course.course_id
sec_id [ TEXT ]
semester [ TEXT ]
year [ INT ]
building [ TEXT ] section.building = classroom.building
room_number [ TEXT ] section.room_number = classroom.room_number
time_slot_id [ TEXT ]

teaches :
ID [ TEXT ] primary_key teaches.ID = instructor.ID
course_id [ TEXT ] teaches.course_id = section.course_id
sec_id [ TEXT ] teaches.sec_id = section.sec_id
semester [ TEXT ] teaches.semester = section.semester
year [ INT ] teaches.year = section.year

student :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] student.dept_name = department.dept_name
tot_cred [ INT ]

takes :
ID [ TEXT ] primary_key takes.ID = student.ID
course_id [ TEXT ] takes.course_id = section.course_id
sec_id [ TEXT ] takes.sec_id = section.sec_id
semester [ TEXT ] takes.semester = section.semester
year [ INT ] takes.year = section.year
grade [ TEXT ]

advisor :
s_ID [ TEXT ] primary_key advisor.s_ID = student.ID
i_ID [ TEXT ] advisor.i_ID = instructor.ID

time_slot :
time_slot_id [ TEXT ] primary_key
day [ TEXT ]
start_hr [ INT ]
start_min [ INT ]
end_hr [ INT ]
end_min [ INT ]

prereq :
course_id [ TEXT ] primary_key prereq.course_id = course.course_id
prereq_id [ TEXT ] prereq.prereq_id = course.course_id

Please write me a SQL statement that answers the following question: What are the titles of courses that are in the Statistics department but not the Psychology department? [/INST]

Output: SELECT title FROM course WHERE dept_name  =  'Statistics' EXCEPT SELECT title FROM course WHERE dept_name  =  'Psychology';


Input:
[INST] Here is a database schema:
classroom :
building [ TEXT ] primary_key
room_number [ TEXT ]
capacity [ INT ]

department :
dept_name [ TEXT ] primary_key
building [ TEXT ]
budget [ INT ]

course :
course_id [ TEXT ] primary_key
title [ TEXT ]
dept_name [ TEXT ] course.dept_name = department.dept_name
credits [ INT ]

instructor :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] instructor.dept_name = department.dept_name
salary [ INT ]

section :
course_id [ TEXT ] primary_key section.course_id = course.course_id
sec_id [ TEXT ]
semester [ TEXT ]
year [ INT ]
building [ TEXT ] section.building = classroom.building
room_number [ TEXT ] section.room_number = classroom.room_number
time_slot_id [ TEXT ]

teaches :
ID [ TEXT ] primary_key teaches.ID = instructor.ID
course_id [ TEXT ] teaches.course_id = section.course_id
sec_id [ TEXT ] teaches.sec_id = section.sec_id
semester [ TEXT ] teaches.semester = section.semester
year [ INT ] teaches.year = section.year

student :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] student.dept_name = department.dept_name
tot_cred [ INT ]

takes :
ID [ TEXT ] primary_key takes.ID = student.ID
course_id [ TEXT ] takes.course_id = section.course_id
sec_id [ TEXT ] takes.sec_id = section.sec_id
semester [ TEXT ] takes.semester = section.semester
year [ INT ] takes.year = section.year
grade [ TEXT ]

advisor :
s_ID [ TEXT ] primary_key advisor.s_ID = student.ID
i_ID [ TEXT ] advisor.i_ID = instructor.ID

time_slot :
time_slot_id [ TEXT ] primary_key
day [ TEXT ]
start_hr [ INT ]
start_min [ INT ]
end_hr [ INT ]
end_min [ INT ]

prereq :
course_id [ TEXT ] primary_key prereq.course_id = course.course_id
prereq_id [ TEXT ] prereq.prereq_id = course.course_id

Please write me a SQL statement that answers the following question: Find the id of instructors who taught a class in Fall 2009 but not in Spring 2010. [/INST]

Output: SELECT id FROM teaches WHERE semester  =  'Fall' AND YEAR  =  2009 EXCEPT SELECT id FROM teaches WHERE semester  =  'Spring' AND YEAR  =  2010;


Input:
[INST] Here is a database schema:
classroom :
building [ TEXT ] primary_key
room_number [ TEXT ]
capacity [ INT ]

department :
dept_name [ TEXT ] primary_key
building [ TEXT ]
budget [ INT ]

course :
course_id [ TEXT ] primary_key
title [ TEXT ]
dept_name [ TEXT ] course.dept_name = department.dept_name
credits [ INT ]

instructor :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] instructor.dept_name = department.dept_name
salary [ INT ]

section :
course_id [ TEXT ] primary_key section.course_id = course.course_id
sec_id [ TEXT ]
semester [ TEXT ]
year [ INT ]
building [ TEXT ] section.building = classroom.building
room_number [ TEXT ] section.room_number = classroom.room_number
time_slot_id [ TEXT ]

teaches :
ID [ TEXT ] primary_key teaches.ID = instructor.ID
course_id [ TEXT ] teaches.course_id = section.course_id
sec_id [ TEXT ] teaches.sec_id = section.sec_id
semester [ TEXT ] teaches.semester = section.semester
year [ INT ] teaches.year = section.year

student :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] student.dept_name = department.dept_name
tot_cred [ INT ]

takes :
ID [ TEXT ] primary_key takes.ID = student.ID
course_id [ TEXT ] takes.course_id = section.course_id
sec_id [ TEXT ] takes.sec_id = section.sec_id
semester [ TEXT ] takes.semester = section.semester
year [ INT ] takes.year = section.year
grade [ TEXT ]

advisor :
s_ID [ TEXT ] primary_key advisor.s_ID = student.ID
i_ID [ TEXT ] advisor.i_ID = instructor.ID

time_slot :
time_slot_id [ TEXT ] primary_key
day [ TEXT ]
start_hr [ INT ]
start_min [ INT ]
end_hr [ INT ]
end_min [ INT ]

prereq :
course_id [ TEXT ] primary_key prereq.course_id = course.course_id
prereq_id [ TEXT ] prereq.prereq_id = course.course_id

Please write me a SQL statement that answers the following question: What are the ids of instructors who taught in the Fall of 2009 but not in the Spring of 2010? [/INST]

Output: SELECT id FROM teaches WHERE semester  =  'Fall' AND YEAR  =  2009 EXCEPT SELECT id FROM teaches WHERE semester  =  'Spring' AND YEAR  =  2010;


Input:
[INST] Here is a database schema:
classroom :
building [ TEXT ] primary_key
room_number [ TEXT ]
capacity [ INT ]

department :
dept_name [ TEXT ] primary_key
building [ TEXT ]
budget [ INT ]

course :
course_id [ TEXT ] primary_key
title [ TEXT ]
dept_name [ TEXT ] course.dept_name = department.dept_name
credits [ INT ]

instructor :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] instructor.dept_name = department.dept_name
salary [ INT ]

section :
course_id [ TEXT ] primary_key section.course_id = course.course_id
sec_id [ TEXT ]
semester [ TEXT ]
year [ INT ]
building [ TEXT ] section.building = classroom.building
room_number [ TEXT ] section.room_number = classroom.room_number
time_slot_id [ TEXT ]

teaches :
ID [ TEXT ] primary_key teaches.ID = instructor.ID
course_id [ TEXT ] teaches.course_id = section.course_id
sec_id [ TEXT ] teaches.sec_id = section.sec_id
semester [ TEXT ] teaches.semester = section.semester
year [ INT ] teaches.year = section.year

student :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] student.dept_name = department.dept_name
tot_cred [ INT ]

takes :
ID [ TEXT ] primary_key takes.ID = student.ID
course_id [ TEXT ] takes.course_id = section.course_id
sec_id [ TEXT ] takes.sec_id = section.sec_id
semester [ TEXT ] takes.semester = section.semester
year [ INT ] takes.year = section.year
grade [ TEXT ]

advisor :
s_ID [ TEXT ] primary_key advisor.s_ID = student.ID
i_ID [ TEXT ] advisor.i_ID = instructor.ID

time_slot :
time_slot_id [ TEXT ] primary_key
day [ TEXT ]
start_hr [ INT ]
start_min [ INT ]
end_hr [ INT ]
end_min [ INT ]

prereq :
course_id [ TEXT ] primary_key prereq.course_id = course.course_id
prereq_id [ TEXT ] prereq.prereq_id = course.course_id

Please write me a SQL statement that answers the following question: Find the name of students who took any class in the years of 2009 and 2010. [/INST]

Output: SELECT DISTINCT T1.name FROM student AS T1 JOIN takes AS T2 ON T1.id  =  T2.id WHERE YEAR  =  2009 OR YEAR  =  2010;


Input:
[INST] Here is a database schema:
classroom :
building [ TEXT ] primary_key
room_number [ TEXT ]
capacity [ INT ]

department :
dept_name [ TEXT ] primary_key
building [ TEXT ]
budget [ INT ]

course :
course_id [ TEXT ] primary_key
title [ TEXT ]
dept_name [ TEXT ] course.dept_name = department.dept_name
credits [ INT ]

instructor :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] instructor.dept_name = department.dept_name
salary [ INT ]

section :
course_id [ TEXT ] primary_key section.course_id = course.course_id
sec_id [ TEXT ]
semester [ TEXT ]
year [ INT ]
building [ TEXT ] section.building = classroom.building
room_number [ TEXT ] section.room_number = classroom.room_number
time_slot_id [ TEXT ]

teaches :
ID [ TEXT ] primary_key teaches.ID = instructor.ID
course_id [ TEXT ] teaches.course_id = section.course_id
sec_id [ TEXT ] teaches.sec_id = section.sec_id
semester [ TEXT ] teaches.semester = section.semester
year [ INT ] teaches.year = section.year

student :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] student.dept_name = department.dept_name
tot_cred [ INT ]

takes :
ID [ TEXT ] primary_key takes.ID = student.ID
course_id [ TEXT ] takes.course_id = section.course_id
sec_id [ TEXT ] takes.sec_id = section.sec_id
semester [ TEXT ] takes.semester = section.semester
year [ INT ] takes.year = section.year
grade [ TEXT ]

advisor :
s_ID [ TEXT ] primary_key advisor.s_ID = student.ID
i_ID [ TEXT ] advisor.i_ID = instructor.ID

time_slot :
time_slot_id [ TEXT ] primary_key
day [ TEXT ]
start_hr [ INT ]
start_min [ INT ]
end_hr [ INT ]
end_min [ INT ]

prereq :
course_id [ TEXT ] primary_key prereq.course_id = course.course_id
prereq_id [ TEXT ] prereq.prereq_id = course.course_id

Please write me a SQL statement that answers the following question: What are the names of the students who took classes in 2009 or 2010? [/INST]

Output: SELECT DISTINCT T1.name FROM student AS T1 JOIN takes AS T2 ON T1.id  =  T2.id WHERE YEAR  =  2009 OR YEAR  =  2010;


Input:
[INST] Here is a database schema:
classroom :
building [ TEXT ] primary_key
room_number [ TEXT ]
capacity [ INT ]

department :
dept_name [ TEXT ] primary_key
building [ TEXT ]
budget [ INT ]

course :
course_id [ TEXT ] primary_key
title [ TEXT ]
dept_name [ TEXT ] course.dept_name = department.dept_name
credits [ INT ]

instructor :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] instructor.dept_name = department.dept_name
salary [ INT ]

section :
course_id [ TEXT ] primary_key section.course_id = course.course_id
sec_id [ TEXT ]
semester [ TEXT ]
year [ INT ]
building [ TEXT ] section.building = classroom.building
room_number [ TEXT ] section.room_number = classroom.room_number
time_slot_id [ TEXT ]

teaches :
ID [ TEXT ] primary_key teaches.ID = instructor.ID
course_id [ TEXT ] teaches.course_id = section.course_id
sec_id [ TEXT ] teaches.sec_id = section.sec_id
semester [ TEXT ] teaches.semester = section.semester
year [ INT ] teaches.year = section.year

student :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] student.dept_name = department.dept_name
tot_cred [ INT ]

takes :
ID [ TEXT ] primary_key takes.ID = student.ID
course_id [ TEXT ] takes.course_id = section.course_id
sec_id [ TEXT ] takes.sec_id = section.sec_id
semester [ TEXT ] takes.semester = section.semester
year [ INT ] takes.year = section.year
grade [ TEXT ]

advisor :
s_ID [ TEXT ] primary_key advisor.s_ID = student.ID
i_ID [ TEXT ] advisor.i_ID = instructor.ID

time_slot :
time_slot_id [ TEXT ] primary_key
day [ TEXT ]
start_hr [ INT ]
start_min [ INT ]
end_hr [ INT ]
end_min [ INT ]

prereq :
course_id [ TEXT ] primary_key prereq.course_id = course.course_id
prereq_id [ TEXT ] prereq.prereq_id = course.course_id

Please write me a SQL statement that answers the following question: Find the names of the top 3 departments that provide the largest amount of courses? [/INST]

Output: SELECT dept_name FROM course GROUP BY dept_name ORDER BY count(*) DESC LIMIT 3;


Input:
[INST] Here is a database schema:
classroom :
building [ TEXT ] primary_key
room_number [ TEXT ]
capacity [ INT ]

department :
dept_name [ TEXT ] primary_key
building [ TEXT ]
budget [ INT ]

course :
course_id [ TEXT ] primary_key
title [ TEXT ]
dept_name [ TEXT ] course.dept_name = department.dept_name
credits [ INT ]

instructor :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] instructor.dept_name = department.dept_name
salary [ INT ]

section :
course_id [ TEXT ] primary_key section.course_id = course.course_id
sec_id [ TEXT ]
semester [ TEXT ]
year [ INT ]
building [ TEXT ] section.building = classroom.building
room_number [ TEXT ] section.room_number = classroom.room_number
time_slot_id [ TEXT ]

teaches :
ID [ TEXT ] primary_key teaches.ID = instructor.ID
course_id [ TEXT ] teaches.course_id = section.course_id
sec_id [ TEXT ] teaches.sec_id = section.sec_id
semester [ TEXT ] teaches.semester = section.semester
year [ INT ] teaches.year = section.year

student :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] student.dept_name = department.dept_name
tot_cred [ INT ]

takes :
ID [ TEXT ] primary_key takes.ID = student.ID
course_id [ TEXT ] takes.course_id = section.course_id
sec_id [ TEXT ] takes.sec_id = section.sec_id
semester [ TEXT ] takes.semester = section.semester
year [ INT ] takes.year = section.year
grade [ TEXT ]

advisor :
s_ID [ TEXT ] primary_key advisor.s_ID = student.ID
i_ID [ TEXT ] advisor.i_ID = instructor.ID

time_slot :
time_slot_id [ TEXT ] primary_key
day [ TEXT ]
start_hr [ INT ]
start_min [ INT ]
end_hr [ INT ]
end_min [ INT ]

prereq :
course_id [ TEXT ] primary_key prereq.course_id = course.course_id
prereq_id [ TEXT ] prereq.prereq_id = course.course_id

Please write me a SQL statement that answers the following question: What are the names of the 3 departments with the most courses? [/INST]

Output: SELECT dept_name FROM course GROUP BY dept_name ORDER BY count(*) DESC LIMIT 3;


Input:
[INST] Here is a database schema:
classroom :
building [ TEXT ] primary_key
room_number [ TEXT ]
capacity [ INT ]

department :
dept_name [ TEXT ] primary_key
building [ TEXT ]
budget [ INT ]

course :
course_id [ TEXT ] primary_key
title [ TEXT ]
dept_name [ TEXT ] course.dept_name = department.dept_name
credits [ INT ]

instructor :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] instructor.dept_name = department.dept_name
salary [ INT ]

section :
course_id [ TEXT ] primary_key section.course_id = course.course_id
sec_id [ TEXT ]
semester [ TEXT ]
year [ INT ]
building [ TEXT ] section.building = classroom.building
room_number [ TEXT ] section.room_number = classroom.room_number
time_slot_id [ TEXT ]

teaches :
ID [ TEXT ] primary_key teaches.ID = instructor.ID
course_id [ TEXT ] teaches.course_id = section.course_id
sec_id [ TEXT ] teaches.sec_id = section.sec_id
semester [ TEXT ] teaches.semester = section.semester
year [ INT ] teaches.year = section.year

student :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] student.dept_name = department.dept_name
tot_cred [ INT ]

takes :
ID [ TEXT ] primary_key takes.ID = student.ID
course_id [ TEXT ] takes.course_id = section.course_id
sec_id [ TEXT ] takes.sec_id = section.sec_id
semester [ TEXT ] takes.semester = section.semester
year [ INT ] takes.year = section.year
grade [ TEXT ]

advisor :
s_ID [ TEXT ] primary_key advisor.s_ID = student.ID
i_ID [ TEXT ] advisor.i_ID = instructor.ID

time_slot :
time_slot_id [ TEXT ] primary_key
day [ TEXT ]
start_hr [ INT ]
start_min [ INT ]
end_hr [ INT ]
end_min [ INT ]

prereq :
course_id [ TEXT ] primary_key prereq.course_id = course.course_id
prereq_id [ TEXT ] prereq.prereq_id = course.course_id

Please write me a SQL statement that answers the following question: Find the name of the department that offers the highest total credits? [/INST]

Output: SELECT dept_name FROM course GROUP BY dept_name ORDER BY sum(credits) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
classroom :
building [ TEXT ] primary_key
room_number [ TEXT ]
capacity [ INT ]

department :
dept_name [ TEXT ] primary_key
building [ TEXT ]
budget [ INT ]

course :
course_id [ TEXT ] primary_key
title [ TEXT ]
dept_name [ TEXT ] course.dept_name = department.dept_name
credits [ INT ]

instructor :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] instructor.dept_name = department.dept_name
salary [ INT ]

section :
course_id [ TEXT ] primary_key section.course_id = course.course_id
sec_id [ TEXT ]
semester [ TEXT ]
year [ INT ]
building [ TEXT ] section.building = classroom.building
room_number [ TEXT ] section.room_number = classroom.room_number
time_slot_id [ TEXT ]

teaches :
ID [ TEXT ] primary_key teaches.ID = instructor.ID
course_id [ TEXT ] teaches.course_id = section.course_id
sec_id [ TEXT ] teaches.sec_id = section.sec_id
semester [ TEXT ] teaches.semester = section.semester
year [ INT ] teaches.year = section.year

student :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] student.dept_name = department.dept_name
tot_cred [ INT ]

takes :
ID [ TEXT ] primary_key takes.ID = student.ID
course_id [ TEXT ] takes.course_id = section.course_id
sec_id [ TEXT ] takes.sec_id = section.sec_id
semester [ TEXT ] takes.semester = section.semester
year [ INT ] takes.year = section.year
grade [ TEXT ]

advisor :
s_ID [ TEXT ] primary_key advisor.s_ID = student.ID
i_ID [ TEXT ] advisor.i_ID = instructor.ID

time_slot :
time_slot_id [ TEXT ] primary_key
day [ TEXT ]
start_hr [ INT ]
start_min [ INT ]
end_hr [ INT ]
end_min [ INT ]

prereq :
course_id [ TEXT ] primary_key prereq.course_id = course.course_id
prereq_id [ TEXT ] prereq.prereq_id = course.course_id

Please write me a SQL statement that answers the following question: What is the name of the department with the most credits? [/INST]

Output: SELECT dept_name FROM course GROUP BY dept_name ORDER BY sum(credits) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
classroom :
building [ TEXT ] primary_key
room_number [ TEXT ]
capacity [ INT ]

department :
dept_name [ TEXT ] primary_key
building [ TEXT ]
budget [ INT ]

course :
course_id [ TEXT ] primary_key
title [ TEXT ]
dept_name [ TEXT ] course.dept_name = department.dept_name
credits [ INT ]

instructor :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] instructor.dept_name = department.dept_name
salary [ INT ]

section :
course_id [ TEXT ] primary_key section.course_id = course.course_id
sec_id [ TEXT ]
semester [ TEXT ]
year [ INT ]
building [ TEXT ] section.building = classroom.building
room_number [ TEXT ] section.room_number = classroom.room_number
time_slot_id [ TEXT ]

teaches :
ID [ TEXT ] primary_key teaches.ID = instructor.ID
course_id [ TEXT ] teaches.course_id = section.course_id
sec_id [ TEXT ] teaches.sec_id = section.sec_id
semester [ TEXT ] teaches.semester = section.semester
year [ INT ] teaches.year = section.year

student :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] student.dept_name = department.dept_name
tot_cred [ INT ]

takes :
ID [ TEXT ] primary_key takes.ID = student.ID
course_id [ TEXT ] takes.course_id = section.course_id
sec_id [ TEXT ] takes.sec_id = section.sec_id
semester [ TEXT ] takes.semester = section.semester
year [ INT ] takes.year = section.year
grade [ TEXT ]

advisor :
s_ID [ TEXT ] primary_key advisor.s_ID = student.ID
i_ID [ TEXT ] advisor.i_ID = instructor.ID

time_slot :
time_slot_id [ TEXT ] primary_key
day [ TEXT ]
start_hr [ INT ]
start_min [ INT ]
end_hr [ INT ]
end_min [ INT ]

prereq :
course_id [ TEXT ] primary_key prereq.course_id = course.course_id
prereq_id [ TEXT ] prereq.prereq_id = course.course_id

Please write me a SQL statement that answers the following question: List the names of all courses ordered by their titles and credits. [/INST]

Output: SELECT title FROM course ORDER BY title ,  credits;


Input:
[INST] Here is a database schema:
classroom :
building [ TEXT ] primary_key
room_number [ TEXT ]
capacity [ INT ]

department :
dept_name [ TEXT ] primary_key
building [ TEXT ]
budget [ INT ]

course :
course_id [ TEXT ] primary_key
title [ TEXT ]
dept_name [ TEXT ] course.dept_name = department.dept_name
credits [ INT ]

instructor :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] instructor.dept_name = department.dept_name
salary [ INT ]

section :
course_id [ TEXT ] primary_key section.course_id = course.course_id
sec_id [ TEXT ]
semester [ TEXT ]
year [ INT ]
building [ TEXT ] section.building = classroom.building
room_number [ TEXT ] section.room_number = classroom.room_number
time_slot_id [ TEXT ]

teaches :
ID [ TEXT ] primary_key teaches.ID = instructor.ID
course_id [ TEXT ] teaches.course_id = section.course_id
sec_id [ TEXT ] teaches.sec_id = section.sec_id
semester [ TEXT ] teaches.semester = section.semester
year [ INT ] teaches.year = section.year

student :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] student.dept_name = department.dept_name
tot_cred [ INT ]

takes :
ID [ TEXT ] primary_key takes.ID = student.ID
course_id [ TEXT ] takes.course_id = section.course_id
sec_id [ TEXT ] takes.sec_id = section.sec_id
semester [ TEXT ] takes.semester = section.semester
year [ INT ] takes.year = section.year
grade [ TEXT ]

advisor :
s_ID [ TEXT ] primary_key advisor.s_ID = student.ID
i_ID [ TEXT ] advisor.i_ID = instructor.ID

time_slot :
time_slot_id [ TEXT ] primary_key
day [ TEXT ]
start_hr [ INT ]
start_min [ INT ]
end_hr [ INT ]
end_min [ INT ]

prereq :
course_id [ TEXT ] primary_key prereq.course_id = course.course_id
prereq_id [ TEXT ] prereq.prereq_id = course.course_id

Please write me a SQL statement that answers the following question: Given the titles of all courses, in order of titles and credits. [/INST]

Output: SELECT title FROM course ORDER BY title ,  credits;


Input:
[INST] Here is a database schema:
classroom :
building [ TEXT ] primary_key
room_number [ TEXT ]
capacity [ INT ]

department :
dept_name [ TEXT ] primary_key
building [ TEXT ]
budget [ INT ]

course :
course_id [ TEXT ] primary_key
title [ TEXT ]
dept_name [ TEXT ] course.dept_name = department.dept_name
credits [ INT ]

instructor :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] instructor.dept_name = department.dept_name
salary [ INT ]

section :
course_id [ TEXT ] primary_key section.course_id = course.course_id
sec_id [ TEXT ]
semester [ TEXT ]
year [ INT ]
building [ TEXT ] section.building = classroom.building
room_number [ TEXT ] section.room_number = classroom.room_number
time_slot_id [ TEXT ]

teaches :
ID [ TEXT ] primary_key teaches.ID = instructor.ID
course_id [ TEXT ] teaches.course_id = section.course_id
sec_id [ TEXT ] teaches.sec_id = section.sec_id
semester [ TEXT ] teaches.semester = section.semester
year [ INT ] teaches.year = section.year

student :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] student.dept_name = department.dept_name
tot_cred [ INT ]

takes :
ID [ TEXT ] primary_key takes.ID = student.ID
course_id [ TEXT ] takes.course_id = section.course_id
sec_id [ TEXT ] takes.sec_id = section.sec_id
semester [ TEXT ] takes.semester = section.semester
year [ INT ] takes.year = section.year
grade [ TEXT ]

advisor :
s_ID [ TEXT ] primary_key advisor.s_ID = student.ID
i_ID [ TEXT ] advisor.i_ID = instructor.ID

time_slot :
time_slot_id [ TEXT ] primary_key
day [ TEXT ]
start_hr [ INT ]
start_min [ INT ]
end_hr [ INT ]
end_min [ INT ]

prereq :
course_id [ TEXT ] primary_key prereq.course_id = course.course_id
prereq_id [ TEXT ] prereq.prereq_id = course.course_id

Please write me a SQL statement that answers the following question: Which department has the lowest budget? [/INST]

Output: SELECT dept_name FROM department ORDER BY budget LIMIT 1;


Input:
[INST] Here is a database schema:
classroom :
building [ TEXT ] primary_key
room_number [ TEXT ]
capacity [ INT ]

department :
dept_name [ TEXT ] primary_key
building [ TEXT ]
budget [ INT ]

course :
course_id [ TEXT ] primary_key
title [ TEXT ]
dept_name [ TEXT ] course.dept_name = department.dept_name
credits [ INT ]

instructor :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] instructor.dept_name = department.dept_name
salary [ INT ]

section :
course_id [ TEXT ] primary_key section.course_id = course.course_id
sec_id [ TEXT ]
semester [ TEXT ]
year [ INT ]
building [ TEXT ] section.building = classroom.building
room_number [ TEXT ] section.room_number = classroom.room_number
time_slot_id [ TEXT ]

teaches :
ID [ TEXT ] primary_key teaches.ID = instructor.ID
course_id [ TEXT ] teaches.course_id = section.course_id
sec_id [ TEXT ] teaches.sec_id = section.sec_id
semester [ TEXT ] teaches.semester = section.semester
year [ INT ] teaches.year = section.year

student :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] student.dept_name = department.dept_name
tot_cred [ INT ]

takes :
ID [ TEXT ] primary_key takes.ID = student.ID
course_id [ TEXT ] takes.course_id = section.course_id
sec_id [ TEXT ] takes.sec_id = section.sec_id
semester [ TEXT ] takes.semester = section.semester
year [ INT ] takes.year = section.year
grade [ TEXT ]

advisor :
s_ID [ TEXT ] primary_key advisor.s_ID = student.ID
i_ID [ TEXT ] advisor.i_ID = instructor.ID

time_slot :
time_slot_id [ TEXT ] primary_key
day [ TEXT ]
start_hr [ INT ]
start_min [ INT ]
end_hr [ INT ]
end_min [ INT ]

prereq :
course_id [ TEXT ] primary_key prereq.course_id = course.course_id
prereq_id [ TEXT ] prereq.prereq_id = course.course_id

Please write me a SQL statement that answers the following question: Give the name of the department with the lowest budget. [/INST]

Output: SELECT dept_name FROM department ORDER BY budget LIMIT 1;


Input:
[INST] Here is a database schema:
classroom :
building [ TEXT ] primary_key
room_number [ TEXT ]
capacity [ INT ]

department :
dept_name [ TEXT ] primary_key
building [ TEXT ]
budget [ INT ]

course :
course_id [ TEXT ] primary_key
title [ TEXT ]
dept_name [ TEXT ] course.dept_name = department.dept_name
credits [ INT ]

instructor :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] instructor.dept_name = department.dept_name
salary [ INT ]

section :
course_id [ TEXT ] primary_key section.course_id = course.course_id
sec_id [ TEXT ]
semester [ TEXT ]
year [ INT ]
building [ TEXT ] section.building = classroom.building
room_number [ TEXT ] section.room_number = classroom.room_number
time_slot_id [ TEXT ]

teaches :
ID [ TEXT ] primary_key teaches.ID = instructor.ID
course_id [ TEXT ] teaches.course_id = section.course_id
sec_id [ TEXT ] teaches.sec_id = section.sec_id
semester [ TEXT ] teaches.semester = section.semester
year [ INT ] teaches.year = section.year

student :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] student.dept_name = department.dept_name
tot_cred [ INT ]

takes :
ID [ TEXT ] primary_key takes.ID = student.ID
course_id [ TEXT ] takes.course_id = section.course_id
sec_id [ TEXT ] takes.sec_id = section.sec_id
semester [ TEXT ] takes.semester = section.semester
year [ INT ] takes.year = section.year
grade [ TEXT ]

advisor :
s_ID [ TEXT ] primary_key advisor.s_ID = student.ID
i_ID [ TEXT ] advisor.i_ID = instructor.ID

time_slot :
time_slot_id [ TEXT ] primary_key
day [ TEXT ]
start_hr [ INT ]
start_min [ INT ]
end_hr [ INT ]
end_min [ INT ]

prereq :
course_id [ TEXT ] primary_key prereq.course_id = course.course_id
prereq_id [ TEXT ] prereq.prereq_id = course.course_id

Please write me a SQL statement that answers the following question: List the names and buildings of all departments sorted by the budget from large to small. [/INST]

Output: SELECT dept_name ,  building FROM department ORDER BY budget DESC;


Input:
[INST] Here is a database schema:
classroom :
building [ TEXT ] primary_key
room_number [ TEXT ]
capacity [ INT ]

department :
dept_name [ TEXT ] primary_key
building [ TEXT ]
budget [ INT ]

course :
course_id [ TEXT ] primary_key
title [ TEXT ]
dept_name [ TEXT ] course.dept_name = department.dept_name
credits [ INT ]

instructor :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] instructor.dept_name = department.dept_name
salary [ INT ]

section :
course_id [ TEXT ] primary_key section.course_id = course.course_id
sec_id [ TEXT ]
semester [ TEXT ]
year [ INT ]
building [ TEXT ] section.building = classroom.building
room_number [ TEXT ] section.room_number = classroom.room_number
time_slot_id [ TEXT ]

teaches :
ID [ TEXT ] primary_key teaches.ID = instructor.ID
course_id [ TEXT ] teaches.course_id = section.course_id
sec_id [ TEXT ] teaches.sec_id = section.sec_id
semester [ TEXT ] teaches.semester = section.semester
year [ INT ] teaches.year = section.year

student :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] student.dept_name = department.dept_name
tot_cred [ INT ]

takes :
ID [ TEXT ] primary_key takes.ID = student.ID
course_id [ TEXT ] takes.course_id = section.course_id
sec_id [ TEXT ] takes.sec_id = section.sec_id
semester [ TEXT ] takes.semester = section.semester
year [ INT ] takes.year = section.year
grade [ TEXT ]

advisor :
s_ID [ TEXT ] primary_key advisor.s_ID = student.ID
i_ID [ TEXT ] advisor.i_ID = instructor.ID

time_slot :
time_slot_id [ TEXT ] primary_key
day [ TEXT ]
start_hr [ INT ]
start_min [ INT ]
end_hr [ INT ]
end_min [ INT ]

prereq :
course_id [ TEXT ] primary_key prereq.course_id = course.course_id
prereq_id [ TEXT ] prereq.prereq_id = course.course_id

Please write me a SQL statement that answers the following question: What are the names and buildings of the deparments, sorted by budget descending? [/INST]

Output: SELECT dept_name ,  building FROM department ORDER BY budget DESC;


Input:
[INST] Here is a database schema:
classroom :
building [ TEXT ] primary_key
room_number [ TEXT ]
capacity [ INT ]

department :
dept_name [ TEXT ] primary_key
building [ TEXT ]
budget [ INT ]

course :
course_id [ TEXT ] primary_key
title [ TEXT ]
dept_name [ TEXT ] course.dept_name = department.dept_name
credits [ INT ]

instructor :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] instructor.dept_name = department.dept_name
salary [ INT ]

section :
course_id [ TEXT ] primary_key section.course_id = course.course_id
sec_id [ TEXT ]
semester [ TEXT ]
year [ INT ]
building [ TEXT ] section.building = classroom.building
room_number [ TEXT ] section.room_number = classroom.room_number
time_slot_id [ TEXT ]

teaches :
ID [ TEXT ] primary_key teaches.ID = instructor.ID
course_id [ TEXT ] teaches.course_id = section.course_id
sec_id [ TEXT ] teaches.sec_id = section.sec_id
semester [ TEXT ] teaches.semester = section.semester
year [ INT ] teaches.year = section.year

student :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] student.dept_name = department.dept_name
tot_cred [ INT ]

takes :
ID [ TEXT ] primary_key takes.ID = student.ID
course_id [ TEXT ] takes.course_id = section.course_id
sec_id [ TEXT ] takes.sec_id = section.sec_id
semester [ TEXT ] takes.semester = section.semester
year [ INT ] takes.year = section.year
grade [ TEXT ]

advisor :
s_ID [ TEXT ] primary_key advisor.s_ID = student.ID
i_ID [ TEXT ] advisor.i_ID = instructor.ID

time_slot :
time_slot_id [ TEXT ] primary_key
day [ TEXT ]
start_hr [ INT ]
start_min [ INT ]
end_hr [ INT ]
end_min [ INT ]

prereq :
course_id [ TEXT ] primary_key prereq.course_id = course.course_id
prereq_id [ TEXT ] prereq.prereq_id = course.course_id

Please write me a SQL statement that answers the following question: Who is the instructor with the highest salary? [/INST]

Output: SELECT name FROM instructor ORDER BY salary DESC LIMIT 1;


Input:
[INST] Here is a database schema:
classroom :
building [ TEXT ] primary_key
room_number [ TEXT ]
capacity [ INT ]

department :
dept_name [ TEXT ] primary_key
building [ TEXT ]
budget [ INT ]

course :
course_id [ TEXT ] primary_key
title [ TEXT ]
dept_name [ TEXT ] course.dept_name = department.dept_name
credits [ INT ]

instructor :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] instructor.dept_name = department.dept_name
salary [ INT ]

section :
course_id [ TEXT ] primary_key section.course_id = course.course_id
sec_id [ TEXT ]
semester [ TEXT ]
year [ INT ]
building [ TEXT ] section.building = classroom.building
room_number [ TEXT ] section.room_number = classroom.room_number
time_slot_id [ TEXT ]

teaches :
ID [ TEXT ] primary_key teaches.ID = instructor.ID
course_id [ TEXT ] teaches.course_id = section.course_id
sec_id [ TEXT ] teaches.sec_id = section.sec_id
semester [ TEXT ] teaches.semester = section.semester
year [ INT ] teaches.year = section.year

student :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] student.dept_name = department.dept_name
tot_cred [ INT ]

takes :
ID [ TEXT ] primary_key takes.ID = student.ID
course_id [ TEXT ] takes.course_id = section.course_id
sec_id [ TEXT ] takes.sec_id = section.sec_id
semester [ TEXT ] takes.semester = section.semester
year [ INT ] takes.year = section.year
grade [ TEXT ]

advisor :
s_ID [ TEXT ] primary_key advisor.s_ID = student.ID
i_ID [ TEXT ] advisor.i_ID = instructor.ID

time_slot :
time_slot_id [ TEXT ] primary_key
day [ TEXT ]
start_hr [ INT ]
start_min [ INT ]
end_hr [ INT ]
end_min [ INT ]

prereq :
course_id [ TEXT ] primary_key prereq.course_id = course.course_id
prereq_id [ TEXT ] prereq.prereq_id = course.course_id

Please write me a SQL statement that answers the following question: Give the name of the highest paid instructor. [/INST]

Output: SELECT name FROM instructor ORDER BY salary DESC LIMIT 1;


Input:
[INST] Here is a database schema:
classroom :
building [ TEXT ] primary_key
room_number [ TEXT ]
capacity [ INT ]

department :
dept_name [ TEXT ] primary_key
building [ TEXT ]
budget [ INT ]

course :
course_id [ TEXT ] primary_key
title [ TEXT ]
dept_name [ TEXT ] course.dept_name = department.dept_name
credits [ INT ]

instructor :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] instructor.dept_name = department.dept_name
salary [ INT ]

section :
course_id [ TEXT ] primary_key section.course_id = course.course_id
sec_id [ TEXT ]
semester [ TEXT ]
year [ INT ]
building [ TEXT ] section.building = classroom.building
room_number [ TEXT ] section.room_number = classroom.room_number
time_slot_id [ TEXT ]

teaches :
ID [ TEXT ] primary_key teaches.ID = instructor.ID
course_id [ TEXT ] teaches.course_id = section.course_id
sec_id [ TEXT ] teaches.sec_id = section.sec_id
semester [ TEXT ] teaches.semester = section.semester
year [ INT ] teaches.year = section.year

student :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] student.dept_name = department.dept_name
tot_cred [ INT ]

takes :
ID [ TEXT ] primary_key takes.ID = student.ID
course_id [ TEXT ] takes.course_id = section.course_id
sec_id [ TEXT ] takes.sec_id = section.sec_id
semester [ TEXT ] takes.semester = section.semester
year [ INT ] takes.year = section.year
grade [ TEXT ]

advisor :
s_ID [ TEXT ] primary_key advisor.s_ID = student.ID
i_ID [ TEXT ] advisor.i_ID = instructor.ID

time_slot :
time_slot_id [ TEXT ] primary_key
day [ TEXT ]
start_hr [ INT ]
start_min [ INT ]
end_hr [ INT ]
end_min [ INT ]

prereq :
course_id [ TEXT ] primary_key prereq.course_id = course.course_id
prereq_id [ TEXT ] prereq.prereq_id = course.course_id

Please write me a SQL statement that answers the following question: List the information of all instructors ordered by their salary in ascending order. [/INST]

Output: SELECT * FROM instructor ORDER BY salary;


Input:
[INST] Here is a database schema:
classroom :
building [ TEXT ] primary_key
room_number [ TEXT ]
capacity [ INT ]

department :
dept_name [ TEXT ] primary_key
building [ TEXT ]
budget [ INT ]

course :
course_id [ TEXT ] primary_key
title [ TEXT ]
dept_name [ TEXT ] course.dept_name = department.dept_name
credits [ INT ]

instructor :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] instructor.dept_name = department.dept_name
salary [ INT ]

section :
course_id [ TEXT ] primary_key section.course_id = course.course_id
sec_id [ TEXT ]
semester [ TEXT ]
year [ INT ]
building [ TEXT ] section.building = classroom.building
room_number [ TEXT ] section.room_number = classroom.room_number
time_slot_id [ TEXT ]

teaches :
ID [ TEXT ] primary_key teaches.ID = instructor.ID
course_id [ TEXT ] teaches.course_id = section.course_id
sec_id [ TEXT ] teaches.sec_id = section.sec_id
semester [ TEXT ] teaches.semester = section.semester
year [ INT ] teaches.year = section.year

student :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] student.dept_name = department.dept_name
tot_cred [ INT ]

takes :
ID [ TEXT ] primary_key takes.ID = student.ID
course_id [ TEXT ] takes.course_id = section.course_id
sec_id [ TEXT ] takes.sec_id = section.sec_id
semester [ TEXT ] takes.semester = section.semester
year [ INT ] takes.year = section.year
grade [ TEXT ]

advisor :
s_ID [ TEXT ] primary_key advisor.s_ID = student.ID
i_ID [ TEXT ] advisor.i_ID = instructor.ID

time_slot :
time_slot_id [ TEXT ] primary_key
day [ TEXT ]
start_hr [ INT ]
start_min [ INT ]
end_hr [ INT ]
end_min [ INT ]

prereq :
course_id [ TEXT ] primary_key prereq.course_id = course.course_id
prereq_id [ TEXT ] prereq.prereq_id = course.course_id

Please write me a SQL statement that answers the following question: Give all information regarding instructors, in order of salary from least to greatest. [/INST]

Output: SELECT * FROM instructor ORDER BY salary;


Input:
[INST] Here is a database schema:
classroom :
building [ TEXT ] primary_key
room_number [ TEXT ]
capacity [ INT ]

department :
dept_name [ TEXT ] primary_key
building [ TEXT ]
budget [ INT ]

course :
course_id [ TEXT ] primary_key
title [ TEXT ]
dept_name [ TEXT ] course.dept_name = department.dept_name
credits [ INT ]

instructor :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] instructor.dept_name = department.dept_name
salary [ INT ]

section :
course_id [ TEXT ] primary_key section.course_id = course.course_id
sec_id [ TEXT ]
semester [ TEXT ]
year [ INT ]
building [ TEXT ] section.building = classroom.building
room_number [ TEXT ] section.room_number = classroom.room_number
time_slot_id [ TEXT ]

teaches :
ID [ TEXT ] primary_key teaches.ID = instructor.ID
course_id [ TEXT ] teaches.course_id = section.course_id
sec_id [ TEXT ] teaches.sec_id = section.sec_id
semester [ TEXT ] teaches.semester = section.semester
year [ INT ] teaches.year = section.year

student :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] student.dept_name = department.dept_name
tot_cred [ INT ]

takes :
ID [ TEXT ] primary_key takes.ID = student.ID
course_id [ TEXT ] takes.course_id = section.course_id
sec_id [ TEXT ] takes.sec_id = section.sec_id
semester [ TEXT ] takes.semester = section.semester
year [ INT ] takes.year = section.year
grade [ TEXT ]

advisor :
s_ID [ TEXT ] primary_key advisor.s_ID = student.ID
i_ID [ TEXT ] advisor.i_ID = instructor.ID

time_slot :
time_slot_id [ TEXT ] primary_key
day [ TEXT ]
start_hr [ INT ]
start_min [ INT ]
end_hr [ INT ]
end_min [ INT ]

prereq :
course_id [ TEXT ] primary_key prereq.course_id = course.course_id
prereq_id [ TEXT ] prereq.prereq_id = course.course_id

Please write me a SQL statement that answers the following question: Find the name of the students and their department names sorted by their total credits in ascending order. [/INST]

Output: SELECT name ,  dept_name FROM student ORDER BY tot_cred;


Input:
[INST] Here is a database schema:
classroom :
building [ TEXT ] primary_key
room_number [ TEXT ]
capacity [ INT ]

department :
dept_name [ TEXT ] primary_key
building [ TEXT ]
budget [ INT ]

course :
course_id [ TEXT ] primary_key
title [ TEXT ]
dept_name [ TEXT ] course.dept_name = department.dept_name
credits [ INT ]

instructor :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] instructor.dept_name = department.dept_name
salary [ INT ]

section :
course_id [ TEXT ] primary_key section.course_id = course.course_id
sec_id [ TEXT ]
semester [ TEXT ]
year [ INT ]
building [ TEXT ] section.building = classroom.building
room_number [ TEXT ] section.room_number = classroom.room_number
time_slot_id [ TEXT ]

teaches :
ID [ TEXT ] primary_key teaches.ID = instructor.ID
course_id [ TEXT ] teaches.course_id = section.course_id
sec_id [ TEXT ] teaches.sec_id = section.sec_id
semester [ TEXT ] teaches.semester = section.semester
year [ INT ] teaches.year = section.year

student :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] student.dept_name = department.dept_name
tot_cred [ INT ]

takes :
ID [ TEXT ] primary_key takes.ID = student.ID
course_id [ TEXT ] takes.course_id = section.course_id
sec_id [ TEXT ] takes.sec_id = section.sec_id
semester [ TEXT ] takes.semester = section.semester
year [ INT ] takes.year = section.year
grade [ TEXT ]

advisor :
s_ID [ TEXT ] primary_key advisor.s_ID = student.ID
i_ID [ TEXT ] advisor.i_ID = instructor.ID

time_slot :
time_slot_id [ TEXT ] primary_key
day [ TEXT ]
start_hr [ INT ]
start_min [ INT ]
end_hr [ INT ]
end_min [ INT ]

prereq :
course_id [ TEXT ] primary_key prereq.course_id = course.course_id
prereq_id [ TEXT ] prereq.prereq_id = course.course_id

Please write me a SQL statement that answers the following question: What are the names of students and their respective departments, ordered by number of credits from least to greatest? [/INST]

Output: SELECT name ,  dept_name FROM student ORDER BY tot_cred;


Input:
[INST] Here is a database schema:
classroom :
building [ TEXT ] primary_key
room_number [ TEXT ]
capacity [ INT ]

department :
dept_name [ TEXT ] primary_key
building [ TEXT ]
budget [ INT ]

course :
course_id [ TEXT ] primary_key
title [ TEXT ]
dept_name [ TEXT ] course.dept_name = department.dept_name
credits [ INT ]

instructor :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] instructor.dept_name = department.dept_name
salary [ INT ]

section :
course_id [ TEXT ] primary_key section.course_id = course.course_id
sec_id [ TEXT ]
semester [ TEXT ]
year [ INT ]
building [ TEXT ] section.building = classroom.building
room_number [ TEXT ] section.room_number = classroom.room_number
time_slot_id [ TEXT ]

teaches :
ID [ TEXT ] primary_key teaches.ID = instructor.ID
course_id [ TEXT ] teaches.course_id = section.course_id
sec_id [ TEXT ] teaches.sec_id = section.sec_id
semester [ TEXT ] teaches.semester = section.semester
year [ INT ] teaches.year = section.year

student :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] student.dept_name = department.dept_name
tot_cred [ INT ]

takes :
ID [ TEXT ] primary_key takes.ID = student.ID
course_id [ TEXT ] takes.course_id = section.course_id
sec_id [ TEXT ] takes.sec_id = section.sec_id
semester [ TEXT ] takes.semester = section.semester
year [ INT ] takes.year = section.year
grade [ TEXT ]

advisor :
s_ID [ TEXT ] primary_key advisor.s_ID = student.ID
i_ID [ TEXT ] advisor.i_ID = instructor.ID

time_slot :
time_slot_id [ TEXT ] primary_key
day [ TEXT ]
start_hr [ INT ]
start_min [ INT ]
end_hr [ INT ]
end_min [ INT ]

prereq :
course_id [ TEXT ] primary_key prereq.course_id = course.course_id
prereq_id [ TEXT ] prereq.prereq_id = course.course_id

Please write me a SQL statement that answers the following question: list in alphabetic order all course names and their instructors' names in year 2008. [/INST]

Output: SELECT T1.title ,  T3.name FROM course AS T1 JOIN teaches AS T2 ON T1.course_id  =  T2.course_id JOIN instructor AS T3 ON T2.id  =  T3.id WHERE YEAR  =  2008 ORDER BY T1.title;


Input:
[INST] Here is a database schema:
classroom :
building [ TEXT ] primary_key
room_number [ TEXT ]
capacity [ INT ]

department :
dept_name [ TEXT ] primary_key
building [ TEXT ]
budget [ INT ]

course :
course_id [ TEXT ] primary_key
title [ TEXT ]
dept_name [ TEXT ] course.dept_name = department.dept_name
credits [ INT ]

instructor :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] instructor.dept_name = department.dept_name
salary [ INT ]

section :
course_id [ TEXT ] primary_key section.course_id = course.course_id
sec_id [ TEXT ]
semester [ TEXT ]
year [ INT ]
building [ TEXT ] section.building = classroom.building
room_number [ TEXT ] section.room_number = classroom.room_number
time_slot_id [ TEXT ]

teaches :
ID [ TEXT ] primary_key teaches.ID = instructor.ID
course_id [ TEXT ] teaches.course_id = section.course_id
sec_id [ TEXT ] teaches.sec_id = section.sec_id
semester [ TEXT ] teaches.semester = section.semester
year [ INT ] teaches.year = section.year

student :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] student.dept_name = department.dept_name
tot_cred [ INT ]

takes :
ID [ TEXT ] primary_key takes.ID = student.ID
course_id [ TEXT ] takes.course_id = section.course_id
sec_id [ TEXT ] takes.sec_id = section.sec_id
semester [ TEXT ] takes.semester = section.semester
year [ INT ] takes.year = section.year
grade [ TEXT ]

advisor :
s_ID [ TEXT ] primary_key advisor.s_ID = student.ID
i_ID [ TEXT ] advisor.i_ID = instructor.ID

time_slot :
time_slot_id [ TEXT ] primary_key
day [ TEXT ]
start_hr [ INT ]
start_min [ INT ]
end_hr [ INT ]
end_min [ INT ]

prereq :
course_id [ TEXT ] primary_key prereq.course_id = course.course_id
prereq_id [ TEXT ] prereq.prereq_id = course.course_id

Please write me a SQL statement that answers the following question: Show all titles and their instructors' names for courses in 2008, in alphabetical order by title. [/INST]

Output: SELECT T1.title ,  T3.name FROM course AS T1 JOIN teaches AS T2 ON T1.course_id  =  T2.course_id JOIN instructor AS T3 ON T2.id  =  T3.id WHERE YEAR  =  2008 ORDER BY T1.title;


Input:
[INST] Here is a database schema:
classroom :
building [ TEXT ] primary_key
room_number [ TEXT ]
capacity [ INT ]

department :
dept_name [ TEXT ] primary_key
building [ TEXT ]
budget [ INT ]

course :
course_id [ TEXT ] primary_key
title [ TEXT ]
dept_name [ TEXT ] course.dept_name = department.dept_name
credits [ INT ]

instructor :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] instructor.dept_name = department.dept_name
salary [ INT ]

section :
course_id [ TEXT ] primary_key section.course_id = course.course_id
sec_id [ TEXT ]
semester [ TEXT ]
year [ INT ]
building [ TEXT ] section.building = classroom.building
room_number [ TEXT ] section.room_number = classroom.room_number
time_slot_id [ TEXT ]

teaches :
ID [ TEXT ] primary_key teaches.ID = instructor.ID
course_id [ TEXT ] teaches.course_id = section.course_id
sec_id [ TEXT ] teaches.sec_id = section.sec_id
semester [ TEXT ] teaches.semester = section.semester
year [ INT ] teaches.year = section.year

student :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] student.dept_name = department.dept_name
tot_cred [ INT ]

takes :
ID [ TEXT ] primary_key takes.ID = student.ID
course_id [ TEXT ] takes.course_id = section.course_id
sec_id [ TEXT ] takes.sec_id = section.sec_id
semester [ TEXT ] takes.semester = section.semester
year [ INT ] takes.year = section.year
grade [ TEXT ]

advisor :
s_ID [ TEXT ] primary_key advisor.s_ID = student.ID
i_ID [ TEXT ] advisor.i_ID = instructor.ID

time_slot :
time_slot_id [ TEXT ] primary_key
day [ TEXT ]
start_hr [ INT ]
start_min [ INT ]
end_hr [ INT ]
end_min [ INT ]

prereq :
course_id [ TEXT ] primary_key prereq.course_id = course.course_id
prereq_id [ TEXT ] prereq.prereq_id = course.course_id

Please write me a SQL statement that answers the following question: Find the name of instructors who are advising more than one student. [/INST]

Output: SELECT T1.name FROM instructor AS T1 JOIN advisor AS T2 ON T1.id  =  T2.i_id GROUP BY T2.i_id HAVING count(*)  >  1;


Input:
[INST] Here is a database schema:
classroom :
building [ TEXT ] primary_key
room_number [ TEXT ]
capacity [ INT ]

department :
dept_name [ TEXT ] primary_key
building [ TEXT ]
budget [ INT ]

course :
course_id [ TEXT ] primary_key
title [ TEXT ]
dept_name [ TEXT ] course.dept_name = department.dept_name
credits [ INT ]

instructor :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] instructor.dept_name = department.dept_name
salary [ INT ]

section :
course_id [ TEXT ] primary_key section.course_id = course.course_id
sec_id [ TEXT ]
semester [ TEXT ]
year [ INT ]
building [ TEXT ] section.building = classroom.building
room_number [ TEXT ] section.room_number = classroom.room_number
time_slot_id [ TEXT ]

teaches :
ID [ TEXT ] primary_key teaches.ID = instructor.ID
course_id [ TEXT ] teaches.course_id = section.course_id
sec_id [ TEXT ] teaches.sec_id = section.sec_id
semester [ TEXT ] teaches.semester = section.semester
year [ INT ] teaches.year = section.year

student :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] student.dept_name = department.dept_name
tot_cred [ INT ]

takes :
ID [ TEXT ] primary_key takes.ID = student.ID
course_id [ TEXT ] takes.course_id = section.course_id
sec_id [ TEXT ] takes.sec_id = section.sec_id
semester [ TEXT ] takes.semester = section.semester
year [ INT ] takes.year = section.year
grade [ TEXT ]

advisor :
s_ID [ TEXT ] primary_key advisor.s_ID = student.ID
i_ID [ TEXT ] advisor.i_ID = instructor.ID

time_slot :
time_slot_id [ TEXT ] primary_key
day [ TEXT ]
start_hr [ INT ]
start_min [ INT ]
end_hr [ INT ]
end_min [ INT ]

prereq :
course_id [ TEXT ] primary_key prereq.course_id = course.course_id
prereq_id [ TEXT ] prereq.prereq_id = course.course_id

Please write me a SQL statement that answers the following question: What are the names of instructors who advise more than one student? [/INST]

Output: SELECT T1.name FROM instructor AS T1 JOIN advisor AS T2 ON T1.id  =  T2.i_id GROUP BY T2.i_id HAVING count(*)  >  1;


Input:
[INST] Here is a database schema:
classroom :
building [ TEXT ] primary_key
room_number [ TEXT ]
capacity [ INT ]

department :
dept_name [ TEXT ] primary_key
building [ TEXT ]
budget [ INT ]

course :
course_id [ TEXT ] primary_key
title [ TEXT ]
dept_name [ TEXT ] course.dept_name = department.dept_name
credits [ INT ]

instructor :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] instructor.dept_name = department.dept_name
salary [ INT ]

section :
course_id [ TEXT ] primary_key section.course_id = course.course_id
sec_id [ TEXT ]
semester [ TEXT ]
year [ INT ]
building [ TEXT ] section.building = classroom.building
room_number [ TEXT ] section.room_number = classroom.room_number
time_slot_id [ TEXT ]

teaches :
ID [ TEXT ] primary_key teaches.ID = instructor.ID
course_id [ TEXT ] teaches.course_id = section.course_id
sec_id [ TEXT ] teaches.sec_id = section.sec_id
semester [ TEXT ] teaches.semester = section.semester
year [ INT ] teaches.year = section.year

student :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] student.dept_name = department.dept_name
tot_cred [ INT ]

takes :
ID [ TEXT ] primary_key takes.ID = student.ID
course_id [ TEXT ] takes.course_id = section.course_id
sec_id [ TEXT ] takes.sec_id = section.sec_id
semester [ TEXT ] takes.semester = section.semester
year [ INT ] takes.year = section.year
grade [ TEXT ]

advisor :
s_ID [ TEXT ] primary_key advisor.s_ID = student.ID
i_ID [ TEXT ] advisor.i_ID = instructor.ID

time_slot :
time_slot_id [ TEXT ] primary_key
day [ TEXT ]
start_hr [ INT ]
start_min [ INT ]
end_hr [ INT ]
end_min [ INT ]

prereq :
course_id [ TEXT ] primary_key prereq.course_id = course.course_id
prereq_id [ TEXT ] prereq.prereq_id = course.course_id

Please write me a SQL statement that answers the following question: Find the name of the students who have more than one advisor? [/INST]

Output: SELECT T1.name FROM student AS T1 JOIN advisor AS T2 ON T1.id  =  T2.s_id GROUP BY T2.s_id HAVING count(*)  >  1;


Input:
[INST] Here is a database schema:
classroom :
building [ TEXT ] primary_key
room_number [ TEXT ]
capacity [ INT ]

department :
dept_name [ TEXT ] primary_key
building [ TEXT ]
budget [ INT ]

course :
course_id [ TEXT ] primary_key
title [ TEXT ]
dept_name [ TEXT ] course.dept_name = department.dept_name
credits [ INT ]

instructor :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] instructor.dept_name = department.dept_name
salary [ INT ]

section :
course_id [ TEXT ] primary_key section.course_id = course.course_id
sec_id [ TEXT ]
semester [ TEXT ]
year [ INT ]
building [ TEXT ] section.building = classroom.building
room_number [ TEXT ] section.room_number = classroom.room_number
time_slot_id [ TEXT ]

teaches :
ID [ TEXT ] primary_key teaches.ID = instructor.ID
course_id [ TEXT ] teaches.course_id = section.course_id
sec_id [ TEXT ] teaches.sec_id = section.sec_id
semester [ TEXT ] teaches.semester = section.semester
year [ INT ] teaches.year = section.year

student :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] student.dept_name = department.dept_name
tot_cred [ INT ]

takes :
ID [ TEXT ] primary_key takes.ID = student.ID
course_id [ TEXT ] takes.course_id = section.course_id
sec_id [ TEXT ] takes.sec_id = section.sec_id
semester [ TEXT ] takes.semester = section.semester
year [ INT ] takes.year = section.year
grade [ TEXT ]

advisor :
s_ID [ TEXT ] primary_key advisor.s_ID = student.ID
i_ID [ TEXT ] advisor.i_ID = instructor.ID

time_slot :
time_slot_id [ TEXT ] primary_key
day [ TEXT ]
start_hr [ INT ]
start_min [ INT ]
end_hr [ INT ]
end_min [ INT ]

prereq :
course_id [ TEXT ] primary_key prereq.course_id = course.course_id
prereq_id [ TEXT ] prereq.prereq_id = course.course_id

Please write me a SQL statement that answers the following question: What are the names of students who have more than one advisor? [/INST]

Output: SELECT T1.name FROM student AS T1 JOIN advisor AS T2 ON T1.id  =  T2.s_id GROUP BY T2.s_id HAVING count(*)  >  1;


Input:
[INST] Here is a database schema:
classroom :
building [ TEXT ] primary_key
room_number [ TEXT ]
capacity [ INT ]

department :
dept_name [ TEXT ] primary_key
building [ TEXT ]
budget [ INT ]

course :
course_id [ TEXT ] primary_key
title [ TEXT ]
dept_name [ TEXT ] course.dept_name = department.dept_name
credits [ INT ]

instructor :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] instructor.dept_name = department.dept_name
salary [ INT ]

section :
course_id [ TEXT ] primary_key section.course_id = course.course_id
sec_id [ TEXT ]
semester [ TEXT ]
year [ INT ]
building [ TEXT ] section.building = classroom.building
room_number [ TEXT ] section.room_number = classroom.room_number
time_slot_id [ TEXT ]

teaches :
ID [ TEXT ] primary_key teaches.ID = instructor.ID
course_id [ TEXT ] teaches.course_id = section.course_id
sec_id [ TEXT ] teaches.sec_id = section.sec_id
semester [ TEXT ] teaches.semester = section.semester
year [ INT ] teaches.year = section.year

student :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] student.dept_name = department.dept_name
tot_cred [ INT ]

takes :
ID [ TEXT ] primary_key takes.ID = student.ID
course_id [ TEXT ] takes.course_id = section.course_id
sec_id [ TEXT ] takes.sec_id = section.sec_id
semester [ TEXT ] takes.semester = section.semester
year [ INT ] takes.year = section.year
grade [ TEXT ]

advisor :
s_ID [ TEXT ] primary_key advisor.s_ID = student.ID
i_ID [ TEXT ] advisor.i_ID = instructor.ID

time_slot :
time_slot_id [ TEXT ] primary_key
day [ TEXT ]
start_hr [ INT ]
start_min [ INT ]
end_hr [ INT ]
end_min [ INT ]

prereq :
course_id [ TEXT ] primary_key prereq.course_id = course.course_id
prereq_id [ TEXT ] prereq.prereq_id = course.course_id

Please write me a SQL statement that answers the following question: Find the number of rooms with more than 50 capacity for each building. [/INST]

Output: SELECT count(*) ,  building FROM classroom WHERE capacity  >  50 GROUP BY building;


Input:
[INST] Here is a database schema:
classroom :
building [ TEXT ] primary_key
room_number [ TEXT ]
capacity [ INT ]

department :
dept_name [ TEXT ] primary_key
building [ TEXT ]
budget [ INT ]

course :
course_id [ TEXT ] primary_key
title [ TEXT ]
dept_name [ TEXT ] course.dept_name = department.dept_name
credits [ INT ]

instructor :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] instructor.dept_name = department.dept_name
salary [ INT ]

section :
course_id [ TEXT ] primary_key section.course_id = course.course_id
sec_id [ TEXT ]
semester [ TEXT ]
year [ INT ]
building [ TEXT ] section.building = classroom.building
room_number [ TEXT ] section.room_number = classroom.room_number
time_slot_id [ TEXT ]

teaches :
ID [ TEXT ] primary_key teaches.ID = instructor.ID
course_id [ TEXT ] teaches.course_id = section.course_id
sec_id [ TEXT ] teaches.sec_id = section.sec_id
semester [ TEXT ] teaches.semester = section.semester
year [ INT ] teaches.year = section.year

student :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] student.dept_name = department.dept_name
tot_cred [ INT ]

takes :
ID [ TEXT ] primary_key takes.ID = student.ID
course_id [ TEXT ] takes.course_id = section.course_id
sec_id [ TEXT ] takes.sec_id = section.sec_id
semester [ TEXT ] takes.semester = section.semester
year [ INT ] takes.year = section.year
grade [ TEXT ]

advisor :
s_ID [ TEXT ] primary_key advisor.s_ID = student.ID
i_ID [ TEXT ] advisor.i_ID = instructor.ID

time_slot :
time_slot_id [ TEXT ] primary_key
day [ TEXT ]
start_hr [ INT ]
start_min [ INT ]
end_hr [ INT ]
end_min [ INT ]

prereq :
course_id [ TEXT ] primary_key prereq.course_id = course.course_id
prereq_id [ TEXT ] prereq.prereq_id = course.course_id

Please write me a SQL statement that answers the following question: How many rooms in each building have a capacity of over 50? [/INST]

Output: SELECT count(*) ,  building FROM classroom WHERE capacity  >  50 GROUP BY building;


Input:
[INST] Here is a database schema:
classroom :
building [ TEXT ] primary_key
room_number [ TEXT ]
capacity [ INT ]

department :
dept_name [ TEXT ] primary_key
building [ TEXT ]
budget [ INT ]

course :
course_id [ TEXT ] primary_key
title [ TEXT ]
dept_name [ TEXT ] course.dept_name = department.dept_name
credits [ INT ]

instructor :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] instructor.dept_name = department.dept_name
salary [ INT ]

section :
course_id [ TEXT ] primary_key section.course_id = course.course_id
sec_id [ TEXT ]
semester [ TEXT ]
year [ INT ]
building [ TEXT ] section.building = classroom.building
room_number [ TEXT ] section.room_number = classroom.room_number
time_slot_id [ TEXT ]

teaches :
ID [ TEXT ] primary_key teaches.ID = instructor.ID
course_id [ TEXT ] teaches.course_id = section.course_id
sec_id [ TEXT ] teaches.sec_id = section.sec_id
semester [ TEXT ] teaches.semester = section.semester
year [ INT ] teaches.year = section.year

student :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] student.dept_name = department.dept_name
tot_cred [ INT ]

takes :
ID [ TEXT ] primary_key takes.ID = student.ID
course_id [ TEXT ] takes.course_id = section.course_id
sec_id [ TEXT ] takes.sec_id = section.sec_id
semester [ TEXT ] takes.semester = section.semester
year [ INT ] takes.year = section.year
grade [ TEXT ]

advisor :
s_ID [ TEXT ] primary_key advisor.s_ID = student.ID
i_ID [ TEXT ] advisor.i_ID = instructor.ID

time_slot :
time_slot_id [ TEXT ] primary_key
day [ TEXT ]
start_hr [ INT ]
start_min [ INT ]
end_hr [ INT ]
end_min [ INT ]

prereq :
course_id [ TEXT ] primary_key prereq.course_id = course.course_id
prereq_id [ TEXT ] prereq.prereq_id = course.course_id

Please write me a SQL statement that answers the following question: Find the maximum and average capacity among rooms in each building. [/INST]

Output: SELECT max(capacity) ,  avg(capacity) ,  building FROM classroom GROUP BY building;


Input:
[INST] Here is a database schema:
classroom :
building [ TEXT ] primary_key
room_number [ TEXT ]
capacity [ INT ]

department :
dept_name [ TEXT ] primary_key
building [ TEXT ]
budget [ INT ]

course :
course_id [ TEXT ] primary_key
title [ TEXT ]
dept_name [ TEXT ] course.dept_name = department.dept_name
credits [ INT ]

instructor :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] instructor.dept_name = department.dept_name
salary [ INT ]

section :
course_id [ TEXT ] primary_key section.course_id = course.course_id
sec_id [ TEXT ]
semester [ TEXT ]
year [ INT ]
building [ TEXT ] section.building = classroom.building
room_number [ TEXT ] section.room_number = classroom.room_number
time_slot_id [ TEXT ]

teaches :
ID [ TEXT ] primary_key teaches.ID = instructor.ID
course_id [ TEXT ] teaches.course_id = section.course_id
sec_id [ TEXT ] teaches.sec_id = section.sec_id
semester [ TEXT ] teaches.semester = section.semester
year [ INT ] teaches.year = section.year

student :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] student.dept_name = department.dept_name
tot_cred [ INT ]

takes :
ID [ TEXT ] primary_key takes.ID = student.ID
course_id [ TEXT ] takes.course_id = section.course_id
sec_id [ TEXT ] takes.sec_id = section.sec_id
semester [ TEXT ] takes.semester = section.semester
year [ INT ] takes.year = section.year
grade [ TEXT ]

advisor :
s_ID [ TEXT ] primary_key advisor.s_ID = student.ID
i_ID [ TEXT ] advisor.i_ID = instructor.ID

time_slot :
time_slot_id [ TEXT ] primary_key
day [ TEXT ]
start_hr [ INT ]
start_min [ INT ]
end_hr [ INT ]
end_min [ INT ]

prereq :
course_id [ TEXT ] primary_key prereq.course_id = course.course_id
prereq_id [ TEXT ] prereq.prereq_id = course.course_id

Please write me a SQL statement that answers the following question: What are the greatest and average capacity for rooms in each building? [/INST]

Output: SELECT max(capacity) ,  avg(capacity) ,  building FROM classroom GROUP BY building;


Input:
[INST] Here is a database schema:
classroom :
building [ TEXT ] primary_key
room_number [ TEXT ]
capacity [ INT ]

department :
dept_name [ TEXT ] primary_key
building [ TEXT ]
budget [ INT ]

course :
course_id [ TEXT ] primary_key
title [ TEXT ]
dept_name [ TEXT ] course.dept_name = department.dept_name
credits [ INT ]

instructor :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] instructor.dept_name = department.dept_name
salary [ INT ]

section :
course_id [ TEXT ] primary_key section.course_id = course.course_id
sec_id [ TEXT ]
semester [ TEXT ]
year [ INT ]
building [ TEXT ] section.building = classroom.building
room_number [ TEXT ] section.room_number = classroom.room_number
time_slot_id [ TEXT ]

teaches :
ID [ TEXT ] primary_key teaches.ID = instructor.ID
course_id [ TEXT ] teaches.course_id = section.course_id
sec_id [ TEXT ] teaches.sec_id = section.sec_id
semester [ TEXT ] teaches.semester = section.semester
year [ INT ] teaches.year = section.year

student :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] student.dept_name = department.dept_name
tot_cred [ INT ]

takes :
ID [ TEXT ] primary_key takes.ID = student.ID
course_id [ TEXT ] takes.course_id = section.course_id
sec_id [ TEXT ] takes.sec_id = section.sec_id
semester [ TEXT ] takes.semester = section.semester
year [ INT ] takes.year = section.year
grade [ TEXT ]

advisor :
s_ID [ TEXT ] primary_key advisor.s_ID = student.ID
i_ID [ TEXT ] advisor.i_ID = instructor.ID

time_slot :
time_slot_id [ TEXT ] primary_key
day [ TEXT ]
start_hr [ INT ]
start_min [ INT ]
end_hr [ INT ]
end_min [ INT ]

prereq :
course_id [ TEXT ] primary_key prereq.course_id = course.course_id
prereq_id [ TEXT ] prereq.prereq_id = course.course_id

Please write me a SQL statement that answers the following question: Find the title of the course that is offered by more than one department. [/INST]

Output: SELECT title FROM course GROUP BY title HAVING count(*)  >  1;


Input:
[INST] Here is a database schema:
classroom :
building [ TEXT ] primary_key
room_number [ TEXT ]
capacity [ INT ]

department :
dept_name [ TEXT ] primary_key
building [ TEXT ]
budget [ INT ]

course :
course_id [ TEXT ] primary_key
title [ TEXT ]
dept_name [ TEXT ] course.dept_name = department.dept_name
credits [ INT ]

instructor :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] instructor.dept_name = department.dept_name
salary [ INT ]

section :
course_id [ TEXT ] primary_key section.course_id = course.course_id
sec_id [ TEXT ]
semester [ TEXT ]
year [ INT ]
building [ TEXT ] section.building = classroom.building
room_number [ TEXT ] section.room_number = classroom.room_number
time_slot_id [ TEXT ]

teaches :
ID [ TEXT ] primary_key teaches.ID = instructor.ID
course_id [ TEXT ] teaches.course_id = section.course_id
sec_id [ TEXT ] teaches.sec_id = section.sec_id
semester [ TEXT ] teaches.semester = section.semester
year [ INT ] teaches.year = section.year

student :
ID [ TEXT ] primary_key
name [ TEXT ]
dept_name [ TEXT ] student.dept_name = department.dept_name
tot_cred [ INT ]

takes :
ID [ TEXT ] primary_key takes.ID = student.ID
course_id [ TEXT ] takes.course_id = section.course_id
sec_id [ TEXT ] takes.sec_id = section.sec_id
semester [ TEXT ] takes.semester = section.semester
year [ INT ] takes.year = section.year
grade [ TEXT ]

advisor :
s_ID [ TEXT ] primary_key advisor.s_ID = student.ID
i_ID [ TEXT ] advisor.i_ID = instructor.ID

time_slot :
time_slot_id [ TEXT ] primary_key
day [ TEXT ]
start_hr [ INT ]
start_min [ INT ]
end_hr [ INT ]
end_min [ INT ]

prereq :
course_id [ TEXT ] primary_key prereq.course_id = course.course_id
prereq_id [ TEXT ] prereq.prereq_id = course.course_id

Please write me a SQL statement that answers the following question: What are the titles of courses that are offered in more than one department? [/INST]

Output: SELECT title FROM course GROUP BY title HAVING count(*)  >  1;