brief_instruction stringlengths 16 224 | instruction stringlengths 687 8.77k | output stringlengths 18 577 |
|---|---|---|
List all information about the assessment notes sorted by date in ascending order. |
-- Language PostgreSQL
-- Tables:
-- Table: reference address types
columns : [['address type code', 'text'], ['address type description', 'text']]
-- Table: reference detention type
columns : [['detention type code', 'text'], ['detention type description', 'text']]
-- Table: reference incident type
columns : [['incident type code', 'text'], ['incident type description', 'text']]
-- Table: addresses
columns : [['address id', 'number'], ['line 1', 'text'], ['line 2', 'text'], ['line 3', 'text'], ['city', 'text'], ['zip postcode', 'text'], ['state province county', 'text'], ['country', 'text'], ['other address details', 'text']]
-- Table: students
columns : [['student id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['date first rental', 'time'], ['date left university', 'time'], ['other student details', 'text']]
-- Table: teachers
columns : [['teacher id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['gender', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['other details', 'text']]
-- Table: assessment notes
columns : [['notes id', 'number'], ['student id', 'number'], ['teacher id', 'number'], ['date of notes', 'time'], ['text of notes', 'text'], ['other details', 'text']]
-- Table: behavior incident
columns : [['incident id', 'number'], ['incident type code', 'text'], ['student id', 'number'], ['date incident start', 'time'], ['date incident end', 'time'], ['incident summary', 'text'], ['recommendations', 'text'], ['other details', 'text']]
-- Table: detention
columns : [['detention id', 'number'], ['detention type code', 'text'], ['teacher id', 'number'], ['datetime detention start', 'time'], ['datetime detention end', 'time'], ['detention summary', 'text'], ['other details', 'text']]
-- Table: student addresses
columns : [['student id', 'number'], ['address id', 'number'], ['date address from', 'time'], ['date address to', 'time'], ['monthly rental', 'number'], ['other details', 'text']]
-- Table: students in detention
columns : [['student id', 'number'], ['detention id', 'number'], ['incident id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `List all information about the assessment notes sorted by date in ascending order.` to a syntactically-correct PostgreSQL query.
| SELECT * FROM Assessment_Notes ORDER BY date_of_notes ASC |
List all cities of addresses in alphabetical order. |
-- Language PostgreSQL
-- Tables:
-- Table: reference address types
columns : [['address type code', 'text'], ['address type description', 'text']]
-- Table: reference detention type
columns : [['detention type code', 'text'], ['detention type description', 'text']]
-- Table: reference incident type
columns : [['incident type code', 'text'], ['incident type description', 'text']]
-- Table: addresses
columns : [['address id', 'number'], ['line 1', 'text'], ['line 2', 'text'], ['line 3', 'text'], ['city', 'text'], ['zip postcode', 'text'], ['state province county', 'text'], ['country', 'text'], ['other address details', 'text']]
-- Table: students
columns : [['student id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['date first rental', 'time'], ['date left university', 'time'], ['other student details', 'text']]
-- Table: teachers
columns : [['teacher id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['gender', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['other details', 'text']]
-- Table: assessment notes
columns : [['notes id', 'number'], ['student id', 'number'], ['teacher id', 'number'], ['date of notes', 'time'], ['text of notes', 'text'], ['other details', 'text']]
-- Table: behavior incident
columns : [['incident id', 'number'], ['incident type code', 'text'], ['student id', 'number'], ['date incident start', 'time'], ['date incident end', 'time'], ['incident summary', 'text'], ['recommendations', 'text'], ['other details', 'text']]
-- Table: detention
columns : [['detention id', 'number'], ['detention type code', 'text'], ['teacher id', 'number'], ['datetime detention start', 'time'], ['datetime detention end', 'time'], ['detention summary', 'text'], ['other details', 'text']]
-- Table: student addresses
columns : [['student id', 'number'], ['address id', 'number'], ['date address from', 'time'], ['date address to', 'time'], ['monthly rental', 'number'], ['other details', 'text']]
-- Table: students in detention
columns : [['student id', 'number'], ['detention id', 'number'], ['incident id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `List all cities of addresses in alphabetical order.` to a syntactically-correct PostgreSQL query.
| SELECT city FROM Addresses ORDER BY city |
Find the first names and last names of teachers in alphabetical order of last name. |
-- Language PostgreSQL
-- Tables:
-- Table: reference address types
columns : [['address type code', 'text'], ['address type description', 'text']]
-- Table: reference detention type
columns : [['detention type code', 'text'], ['detention type description', 'text']]
-- Table: reference incident type
columns : [['incident type code', 'text'], ['incident type description', 'text']]
-- Table: addresses
columns : [['address id', 'number'], ['line 1', 'text'], ['line 2', 'text'], ['line 3', 'text'], ['city', 'text'], ['zip postcode', 'text'], ['state province county', 'text'], ['country', 'text'], ['other address details', 'text']]
-- Table: students
columns : [['student id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['date first rental', 'time'], ['date left university', 'time'], ['other student details', 'text']]
-- Table: teachers
columns : [['teacher id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['gender', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['other details', 'text']]
-- Table: assessment notes
columns : [['notes id', 'number'], ['student id', 'number'], ['teacher id', 'number'], ['date of notes', 'time'], ['text of notes', 'text'], ['other details', 'text']]
-- Table: behavior incident
columns : [['incident id', 'number'], ['incident type code', 'text'], ['student id', 'number'], ['date incident start', 'time'], ['date incident end', 'time'], ['incident summary', 'text'], ['recommendations', 'text'], ['other details', 'text']]
-- Table: detention
columns : [['detention id', 'number'], ['detention type code', 'text'], ['teacher id', 'number'], ['datetime detention start', 'time'], ['datetime detention end', 'time'], ['detention summary', 'text'], ['other details', 'text']]
-- Table: student addresses
columns : [['student id', 'number'], ['address id', 'number'], ['date address from', 'time'], ['date address to', 'time'], ['monthly rental', 'number'], ['other details', 'text']]
-- Table: students in detention
columns : [['student id', 'number'], ['detention id', 'number'], ['incident id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `Find the first names and last names of teachers in alphabetical order of last name.` to a syntactically-correct PostgreSQL query.
| SELECT first_name , last_name FROM Teachers ORDER BY last_name |
Find all information about student addresses, and sort by monthly rental in descending order. |
-- Language PostgreSQL
-- Tables:
-- Table: reference address types
columns : [['address type code', 'text'], ['address type description', 'text']]
-- Table: reference detention type
columns : [['detention type code', 'text'], ['detention type description', 'text']]
-- Table: reference incident type
columns : [['incident type code', 'text'], ['incident type description', 'text']]
-- Table: addresses
columns : [['address id', 'number'], ['line 1', 'text'], ['line 2', 'text'], ['line 3', 'text'], ['city', 'text'], ['zip postcode', 'text'], ['state province county', 'text'], ['country', 'text'], ['other address details', 'text']]
-- Table: students
columns : [['student id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['date first rental', 'time'], ['date left university', 'time'], ['other student details', 'text']]
-- Table: teachers
columns : [['teacher id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['gender', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['other details', 'text']]
-- Table: assessment notes
columns : [['notes id', 'number'], ['student id', 'number'], ['teacher id', 'number'], ['date of notes', 'time'], ['text of notes', 'text'], ['other details', 'text']]
-- Table: behavior incident
columns : [['incident id', 'number'], ['incident type code', 'text'], ['student id', 'number'], ['date incident start', 'time'], ['date incident end', 'time'], ['incident summary', 'text'], ['recommendations', 'text'], ['other details', 'text']]
-- Table: detention
columns : [['detention id', 'number'], ['detention type code', 'text'], ['teacher id', 'number'], ['datetime detention start', 'time'], ['datetime detention end', 'time'], ['detention summary', 'text'], ['other details', 'text']]
-- Table: student addresses
columns : [['student id', 'number'], ['address id', 'number'], ['date address from', 'time'], ['date address to', 'time'], ['monthly rental', 'number'], ['other details', 'text']]
-- Table: students in detention
columns : [['student id', 'number'], ['detention id', 'number'], ['incident id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `Find all information about student addresses, and sort by monthly rental in descending order.` to a syntactically-correct PostgreSQL query.
| SELECT * FROM Student_Addresses ORDER BY monthly_rental DESC |
Find the id and first name of the student that has the most number of assessment notes? |
-- Language PostgreSQL
-- Tables:
-- Table: reference address types
columns : [['address type code', 'text'], ['address type description', 'text']]
-- Table: reference detention type
columns : [['detention type code', 'text'], ['detention type description', 'text']]
-- Table: reference incident type
columns : [['incident type code', 'text'], ['incident type description', 'text']]
-- Table: addresses
columns : [['address id', 'number'], ['line 1', 'text'], ['line 2', 'text'], ['line 3', 'text'], ['city', 'text'], ['zip postcode', 'text'], ['state province county', 'text'], ['country', 'text'], ['other address details', 'text']]
-- Table: students
columns : [['student id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['date first rental', 'time'], ['date left university', 'time'], ['other student details', 'text']]
-- Table: teachers
columns : [['teacher id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['gender', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['other details', 'text']]
-- Table: assessment notes
columns : [['notes id', 'number'], ['student id', 'number'], ['teacher id', 'number'], ['date of notes', 'time'], ['text of notes', 'text'], ['other details', 'text']]
-- Table: behavior incident
columns : [['incident id', 'number'], ['incident type code', 'text'], ['student id', 'number'], ['date incident start', 'time'], ['date incident end', 'time'], ['incident summary', 'text'], ['recommendations', 'text'], ['other details', 'text']]
-- Table: detention
columns : [['detention id', 'number'], ['detention type code', 'text'], ['teacher id', 'number'], ['datetime detention start', 'time'], ['datetime detention end', 'time'], ['detention summary', 'text'], ['other details', 'text']]
-- Table: student addresses
columns : [['student id', 'number'], ['address id', 'number'], ['date address from', 'time'], ['date address to', 'time'], ['monthly rental', 'number'], ['other details', 'text']]
-- Table: students in detention
columns : [['student id', 'number'], ['detention id', 'number'], ['incident id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `Find the id and first name of the student that has the most number of assessment notes?` to a syntactically-correct PostgreSQL query.
| SELECT T1.student_id , T2.first_name FROM Assessment_Notes AS T1 JOIN Students AS T2 ON T1.student_id = T2.student_id GROUP BY T1.student_id ORDER BY count(*) DESC LIMIT 1 |
Find the ids and first names of the 3 teachers that have the most number of assessment notes? |
-- Language PostgreSQL
-- Tables:
-- Table: reference address types
columns : [['address type code', 'text'], ['address type description', 'text']]
-- Table: reference detention type
columns : [['detention type code', 'text'], ['detention type description', 'text']]
-- Table: reference incident type
columns : [['incident type code', 'text'], ['incident type description', 'text']]
-- Table: addresses
columns : [['address id', 'number'], ['line 1', 'text'], ['line 2', 'text'], ['line 3', 'text'], ['city', 'text'], ['zip postcode', 'text'], ['state province county', 'text'], ['country', 'text'], ['other address details', 'text']]
-- Table: students
columns : [['student id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['date first rental', 'time'], ['date left university', 'time'], ['other student details', 'text']]
-- Table: teachers
columns : [['teacher id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['gender', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['other details', 'text']]
-- Table: assessment notes
columns : [['notes id', 'number'], ['student id', 'number'], ['teacher id', 'number'], ['date of notes', 'time'], ['text of notes', 'text'], ['other details', 'text']]
-- Table: behavior incident
columns : [['incident id', 'number'], ['incident type code', 'text'], ['student id', 'number'], ['date incident start', 'time'], ['date incident end', 'time'], ['incident summary', 'text'], ['recommendations', 'text'], ['other details', 'text']]
-- Table: detention
columns : [['detention id', 'number'], ['detention type code', 'text'], ['teacher id', 'number'], ['datetime detention start', 'time'], ['datetime detention end', 'time'], ['detention summary', 'text'], ['other details', 'text']]
-- Table: student addresses
columns : [['student id', 'number'], ['address id', 'number'], ['date address from', 'time'], ['date address to', 'time'], ['monthly rental', 'number'], ['other details', 'text']]
-- Table: students in detention
columns : [['student id', 'number'], ['detention id', 'number'], ['incident id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `Find the ids and first names of the 3 teachers that have the most number of assessment notes?` to a syntactically-correct PostgreSQL query.
| SELECT T1.teacher_id , T2.first_name FROM Assessment_Notes AS T1 JOIN Teachers AS T2 ON T1.teacher_id = T2.teacher_id GROUP BY T1.teacher_id ORDER BY count(*) DESC LIMIT 3 |
Find the id and last name of the student that has the most behavior incidents? |
-- Language PostgreSQL
-- Tables:
-- Table: reference address types
columns : [['address type code', 'text'], ['address type description', 'text']]
-- Table: reference detention type
columns : [['detention type code', 'text'], ['detention type description', 'text']]
-- Table: reference incident type
columns : [['incident type code', 'text'], ['incident type description', 'text']]
-- Table: addresses
columns : [['address id', 'number'], ['line 1', 'text'], ['line 2', 'text'], ['line 3', 'text'], ['city', 'text'], ['zip postcode', 'text'], ['state province county', 'text'], ['country', 'text'], ['other address details', 'text']]
-- Table: students
columns : [['student id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['date first rental', 'time'], ['date left university', 'time'], ['other student details', 'text']]
-- Table: teachers
columns : [['teacher id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['gender', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['other details', 'text']]
-- Table: assessment notes
columns : [['notes id', 'number'], ['student id', 'number'], ['teacher id', 'number'], ['date of notes', 'time'], ['text of notes', 'text'], ['other details', 'text']]
-- Table: behavior incident
columns : [['incident id', 'number'], ['incident type code', 'text'], ['student id', 'number'], ['date incident start', 'time'], ['date incident end', 'time'], ['incident summary', 'text'], ['recommendations', 'text'], ['other details', 'text']]
-- Table: detention
columns : [['detention id', 'number'], ['detention type code', 'text'], ['teacher id', 'number'], ['datetime detention start', 'time'], ['datetime detention end', 'time'], ['detention summary', 'text'], ['other details', 'text']]
-- Table: student addresses
columns : [['student id', 'number'], ['address id', 'number'], ['date address from', 'time'], ['date address to', 'time'], ['monthly rental', 'number'], ['other details', 'text']]
-- Table: students in detention
columns : [['student id', 'number'], ['detention id', 'number'], ['incident id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `Find the id and last name of the student that has the most behavior incidents?` to a syntactically-correct PostgreSQL query.
| SELECT T1.student_id , T2.last_name FROM Behavior_Incident AS T1 JOIN Students AS T2 ON T1.student_id = T2.student_id GROUP BY T1.student_id ORDER BY count(*) DESC LIMIT 1 |
Find the id and last name of the teacher that has the most detentions with detention type code "AFTER"? |
-- Language PostgreSQL
-- Tables:
-- Table: reference address types
columns : [['address type code', 'text'], ['address type description', 'text']]
-- Table: reference detention type
columns : [['detention type code', 'text'], ['detention type description', 'text']]
-- Table: reference incident type
columns : [['incident type code', 'text'], ['incident type description', 'text']]
-- Table: addresses
columns : [['address id', 'number'], ['line 1', 'text'], ['line 2', 'text'], ['line 3', 'text'], ['city', 'text'], ['zip postcode', 'text'], ['state province county', 'text'], ['country', 'text'], ['other address details', 'text']]
-- Table: students
columns : [['student id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['date first rental', 'time'], ['date left university', 'time'], ['other student details', 'text']]
-- Table: teachers
columns : [['teacher id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['gender', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['other details', 'text']]
-- Table: assessment notes
columns : [['notes id', 'number'], ['student id', 'number'], ['teacher id', 'number'], ['date of notes', 'time'], ['text of notes', 'text'], ['other details', 'text']]
-- Table: behavior incident
columns : [['incident id', 'number'], ['incident type code', 'text'], ['student id', 'number'], ['date incident start', 'time'], ['date incident end', 'time'], ['incident summary', 'text'], ['recommendations', 'text'], ['other details', 'text']]
-- Table: detention
columns : [['detention id', 'number'], ['detention type code', 'text'], ['teacher id', 'number'], ['datetime detention start', 'time'], ['datetime detention end', 'time'], ['detention summary', 'text'], ['other details', 'text']]
-- Table: student addresses
columns : [['student id', 'number'], ['address id', 'number'], ['date address from', 'time'], ['date address to', 'time'], ['monthly rental', 'number'], ['other details', 'text']]
-- Table: students in detention
columns : [['student id', 'number'], ['detention id', 'number'], ['incident id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `Find the id and last name of the teacher that has the most detentions with detention type code "AFTER"?` to a syntactically-correct PostgreSQL query.
| SELECT T1.teacher_id , T2.last_name FROM Detention AS T1 JOIN Teachers AS T2 ON T1.teacher_id = T2.teacher_id WHERE T1.detention_type_code = "AFTER" GROUP BY T1.teacher_id ORDER BY count(*) DESC LIMIT 1 |
What are the id and first name of the student whose addresses have the highest average monthly rental? |
-- Language PostgreSQL
-- Tables:
-- Table: reference address types
columns : [['address type code', 'text'], ['address type description', 'text']]
-- Table: reference detention type
columns : [['detention type code', 'text'], ['detention type description', 'text']]
-- Table: reference incident type
columns : [['incident type code', 'text'], ['incident type description', 'text']]
-- Table: addresses
columns : [['address id', 'number'], ['line 1', 'text'], ['line 2', 'text'], ['line 3', 'text'], ['city', 'text'], ['zip postcode', 'text'], ['state province county', 'text'], ['country', 'text'], ['other address details', 'text']]
-- Table: students
columns : [['student id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['date first rental', 'time'], ['date left university', 'time'], ['other student details', 'text']]
-- Table: teachers
columns : [['teacher id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['gender', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['other details', 'text']]
-- Table: assessment notes
columns : [['notes id', 'number'], ['student id', 'number'], ['teacher id', 'number'], ['date of notes', 'time'], ['text of notes', 'text'], ['other details', 'text']]
-- Table: behavior incident
columns : [['incident id', 'number'], ['incident type code', 'text'], ['student id', 'number'], ['date incident start', 'time'], ['date incident end', 'time'], ['incident summary', 'text'], ['recommendations', 'text'], ['other details', 'text']]
-- Table: detention
columns : [['detention id', 'number'], ['detention type code', 'text'], ['teacher id', 'number'], ['datetime detention start', 'time'], ['datetime detention end', 'time'], ['detention summary', 'text'], ['other details', 'text']]
-- Table: student addresses
columns : [['student id', 'number'], ['address id', 'number'], ['date address from', 'time'], ['date address to', 'time'], ['monthly rental', 'number'], ['other details', 'text']]
-- Table: students in detention
columns : [['student id', 'number'], ['detention id', 'number'], ['incident id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `What are the id and first name of the student whose addresses have the highest average monthly rental?` to a syntactically-correct PostgreSQL query.
| SELECT T1.student_id , T2.first_name FROM Student_Addresses AS T1 JOIN Students AS T2 ON T1.student_id = T2.student_id GROUP BY T1.student_id ORDER BY AVG(monthly_rental) DESC LIMIT 1 |
Find the id and city of the student address with the highest average monthly rental. |
-- Language PostgreSQL
-- Tables:
-- Table: reference address types
columns : [['address type code', 'text'], ['address type description', 'text']]
-- Table: reference detention type
columns : [['detention type code', 'text'], ['detention type description', 'text']]
-- Table: reference incident type
columns : [['incident type code', 'text'], ['incident type description', 'text']]
-- Table: addresses
columns : [['address id', 'number'], ['line 1', 'text'], ['line 2', 'text'], ['line 3', 'text'], ['city', 'text'], ['zip postcode', 'text'], ['state province county', 'text'], ['country', 'text'], ['other address details', 'text']]
-- Table: students
columns : [['student id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['date first rental', 'time'], ['date left university', 'time'], ['other student details', 'text']]
-- Table: teachers
columns : [['teacher id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['gender', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['other details', 'text']]
-- Table: assessment notes
columns : [['notes id', 'number'], ['student id', 'number'], ['teacher id', 'number'], ['date of notes', 'time'], ['text of notes', 'text'], ['other details', 'text']]
-- Table: behavior incident
columns : [['incident id', 'number'], ['incident type code', 'text'], ['student id', 'number'], ['date incident start', 'time'], ['date incident end', 'time'], ['incident summary', 'text'], ['recommendations', 'text'], ['other details', 'text']]
-- Table: detention
columns : [['detention id', 'number'], ['detention type code', 'text'], ['teacher id', 'number'], ['datetime detention start', 'time'], ['datetime detention end', 'time'], ['detention summary', 'text'], ['other details', 'text']]
-- Table: student addresses
columns : [['student id', 'number'], ['address id', 'number'], ['date address from', 'time'], ['date address to', 'time'], ['monthly rental', 'number'], ['other details', 'text']]
-- Table: students in detention
columns : [['student id', 'number'], ['detention id', 'number'], ['incident id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `Find the id and city of the student address with the highest average monthly rental.` to a syntactically-correct PostgreSQL query.
| SELECT T2.address_id , T1.city FROM Addresses AS T1 JOIN Student_Addresses AS T2 ON T1.address_id = T2.address_id GROUP BY T2.address_id ORDER BY AVG(monthly_rental) DESC LIMIT 1 |
What are the code and description of the most frequent behavior incident type? |
-- Language PostgreSQL
-- Tables:
-- Table: reference address types
columns : [['address type code', 'text'], ['address type description', 'text']]
-- Table: reference detention type
columns : [['detention type code', 'text'], ['detention type description', 'text']]
-- Table: reference incident type
columns : [['incident type code', 'text'], ['incident type description', 'text']]
-- Table: addresses
columns : [['address id', 'number'], ['line 1', 'text'], ['line 2', 'text'], ['line 3', 'text'], ['city', 'text'], ['zip postcode', 'text'], ['state province county', 'text'], ['country', 'text'], ['other address details', 'text']]
-- Table: students
columns : [['student id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['date first rental', 'time'], ['date left university', 'time'], ['other student details', 'text']]
-- Table: teachers
columns : [['teacher id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['gender', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['other details', 'text']]
-- Table: assessment notes
columns : [['notes id', 'number'], ['student id', 'number'], ['teacher id', 'number'], ['date of notes', 'time'], ['text of notes', 'text'], ['other details', 'text']]
-- Table: behavior incident
columns : [['incident id', 'number'], ['incident type code', 'text'], ['student id', 'number'], ['date incident start', 'time'], ['date incident end', 'time'], ['incident summary', 'text'], ['recommendations', 'text'], ['other details', 'text']]
-- Table: detention
columns : [['detention id', 'number'], ['detention type code', 'text'], ['teacher id', 'number'], ['datetime detention start', 'time'], ['datetime detention end', 'time'], ['detention summary', 'text'], ['other details', 'text']]
-- Table: student addresses
columns : [['student id', 'number'], ['address id', 'number'], ['date address from', 'time'], ['date address to', 'time'], ['monthly rental', 'number'], ['other details', 'text']]
-- Table: students in detention
columns : [['student id', 'number'], ['detention id', 'number'], ['incident id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `What are the code and description of the most frequent behavior incident type?` to a syntactically-correct PostgreSQL query.
| SELECT T1.incident_type_code , T2.incident_type_description FROM Behavior_Incident AS T1 JOIN Ref_Incident_Type AS T2 ON T1.incident_type_code = T2.incident_type_code GROUP BY T1.incident_type_code ORDER BY count(*) DESC LIMIT 1 |
What are the code and description of the least frequent detention type ? |
-- Language PostgreSQL
-- Tables:
-- Table: reference address types
columns : [['address type code', 'text'], ['address type description', 'text']]
-- Table: reference detention type
columns : [['detention type code', 'text'], ['detention type description', 'text']]
-- Table: reference incident type
columns : [['incident type code', 'text'], ['incident type description', 'text']]
-- Table: addresses
columns : [['address id', 'number'], ['line 1', 'text'], ['line 2', 'text'], ['line 3', 'text'], ['city', 'text'], ['zip postcode', 'text'], ['state province county', 'text'], ['country', 'text'], ['other address details', 'text']]
-- Table: students
columns : [['student id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['date first rental', 'time'], ['date left university', 'time'], ['other student details', 'text']]
-- Table: teachers
columns : [['teacher id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['gender', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['other details', 'text']]
-- Table: assessment notes
columns : [['notes id', 'number'], ['student id', 'number'], ['teacher id', 'number'], ['date of notes', 'time'], ['text of notes', 'text'], ['other details', 'text']]
-- Table: behavior incident
columns : [['incident id', 'number'], ['incident type code', 'text'], ['student id', 'number'], ['date incident start', 'time'], ['date incident end', 'time'], ['incident summary', 'text'], ['recommendations', 'text'], ['other details', 'text']]
-- Table: detention
columns : [['detention id', 'number'], ['detention type code', 'text'], ['teacher id', 'number'], ['datetime detention start', 'time'], ['datetime detention end', 'time'], ['detention summary', 'text'], ['other details', 'text']]
-- Table: student addresses
columns : [['student id', 'number'], ['address id', 'number'], ['date address from', 'time'], ['date address to', 'time'], ['monthly rental', 'number'], ['other details', 'text']]
-- Table: students in detention
columns : [['student id', 'number'], ['detention id', 'number'], ['incident id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `What are the code and description of the least frequent detention type ?` to a syntactically-correct PostgreSQL query.
| SELECT T1.detention_type_code , T2.detention_type_description FROM Detention AS T1 JOIN Ref_Detention_Type AS T2 ON T1.detention_type_code = T2.detention_type_code GROUP BY T1.detention_type_code ORDER BY count(*) ASC LIMIT 1 |
Find the dates of assessment notes for students with first name "Fanny". |
-- Language PostgreSQL
-- Tables:
-- Table: reference address types
columns : [['address type code', 'text'], ['address type description', 'text']]
-- Table: reference detention type
columns : [['detention type code', 'text'], ['detention type description', 'text']]
-- Table: reference incident type
columns : [['incident type code', 'text'], ['incident type description', 'text']]
-- Table: addresses
columns : [['address id', 'number'], ['line 1', 'text'], ['line 2', 'text'], ['line 3', 'text'], ['city', 'text'], ['zip postcode', 'text'], ['state province county', 'text'], ['country', 'text'], ['other address details', 'text']]
-- Table: students
columns : [['student id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['date first rental', 'time'], ['date left university', 'time'], ['other student details', 'text']]
-- Table: teachers
columns : [['teacher id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['gender', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['other details', 'text']]
-- Table: assessment notes
columns : [['notes id', 'number'], ['student id', 'number'], ['teacher id', 'number'], ['date of notes', 'time'], ['text of notes', 'text'], ['other details', 'text']]
-- Table: behavior incident
columns : [['incident id', 'number'], ['incident type code', 'text'], ['student id', 'number'], ['date incident start', 'time'], ['date incident end', 'time'], ['incident summary', 'text'], ['recommendations', 'text'], ['other details', 'text']]
-- Table: detention
columns : [['detention id', 'number'], ['detention type code', 'text'], ['teacher id', 'number'], ['datetime detention start', 'time'], ['datetime detention end', 'time'], ['detention summary', 'text'], ['other details', 'text']]
-- Table: student addresses
columns : [['student id', 'number'], ['address id', 'number'], ['date address from', 'time'], ['date address to', 'time'], ['monthly rental', 'number'], ['other details', 'text']]
-- Table: students in detention
columns : [['student id', 'number'], ['detention id', 'number'], ['incident id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `Find the dates of assessment notes for students with first name "Fanny".` to a syntactically-correct PostgreSQL query.
| SELECT T1.date_of_notes FROM Assessment_Notes AS T1 JOIN Students AS T2 ON T1.student_id = T2.student_id WHERE T2.first_name = "Fanny" |
Find the texts of assessment notes for teachers with last name "Schuster". |
-- Language PostgreSQL
-- Tables:
-- Table: reference address types
columns : [['address type code', 'text'], ['address type description', 'text']]
-- Table: reference detention type
columns : [['detention type code', 'text'], ['detention type description', 'text']]
-- Table: reference incident type
columns : [['incident type code', 'text'], ['incident type description', 'text']]
-- Table: addresses
columns : [['address id', 'number'], ['line 1', 'text'], ['line 2', 'text'], ['line 3', 'text'], ['city', 'text'], ['zip postcode', 'text'], ['state province county', 'text'], ['country', 'text'], ['other address details', 'text']]
-- Table: students
columns : [['student id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['date first rental', 'time'], ['date left university', 'time'], ['other student details', 'text']]
-- Table: teachers
columns : [['teacher id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['gender', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['other details', 'text']]
-- Table: assessment notes
columns : [['notes id', 'number'], ['student id', 'number'], ['teacher id', 'number'], ['date of notes', 'time'], ['text of notes', 'text'], ['other details', 'text']]
-- Table: behavior incident
columns : [['incident id', 'number'], ['incident type code', 'text'], ['student id', 'number'], ['date incident start', 'time'], ['date incident end', 'time'], ['incident summary', 'text'], ['recommendations', 'text'], ['other details', 'text']]
-- Table: detention
columns : [['detention id', 'number'], ['detention type code', 'text'], ['teacher id', 'number'], ['datetime detention start', 'time'], ['datetime detention end', 'time'], ['detention summary', 'text'], ['other details', 'text']]
-- Table: student addresses
columns : [['student id', 'number'], ['address id', 'number'], ['date address from', 'time'], ['date address to', 'time'], ['monthly rental', 'number'], ['other details', 'text']]
-- Table: students in detention
columns : [['student id', 'number'], ['detention id', 'number'], ['incident id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `Find the texts of assessment notes for teachers with last name "Schuster".` to a syntactically-correct PostgreSQL query.
| SELECT T1.text_of_notes FROM Assessment_Notes AS T1 JOIN Teachers AS T2 ON T1.teacher_id = T2.teacher_id WHERE T2.last_name = "Schuster" |
Find the start and end dates of behavior incidents of students with last name "Fahey". |
-- Language PostgreSQL
-- Tables:
-- Table: reference address types
columns : [['address type code', 'text'], ['address type description', 'text']]
-- Table: reference detention type
columns : [['detention type code', 'text'], ['detention type description', 'text']]
-- Table: reference incident type
columns : [['incident type code', 'text'], ['incident type description', 'text']]
-- Table: addresses
columns : [['address id', 'number'], ['line 1', 'text'], ['line 2', 'text'], ['line 3', 'text'], ['city', 'text'], ['zip postcode', 'text'], ['state province county', 'text'], ['country', 'text'], ['other address details', 'text']]
-- Table: students
columns : [['student id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['date first rental', 'time'], ['date left university', 'time'], ['other student details', 'text']]
-- Table: teachers
columns : [['teacher id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['gender', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['other details', 'text']]
-- Table: assessment notes
columns : [['notes id', 'number'], ['student id', 'number'], ['teacher id', 'number'], ['date of notes', 'time'], ['text of notes', 'text'], ['other details', 'text']]
-- Table: behavior incident
columns : [['incident id', 'number'], ['incident type code', 'text'], ['student id', 'number'], ['date incident start', 'time'], ['date incident end', 'time'], ['incident summary', 'text'], ['recommendations', 'text'], ['other details', 'text']]
-- Table: detention
columns : [['detention id', 'number'], ['detention type code', 'text'], ['teacher id', 'number'], ['datetime detention start', 'time'], ['datetime detention end', 'time'], ['detention summary', 'text'], ['other details', 'text']]
-- Table: student addresses
columns : [['student id', 'number'], ['address id', 'number'], ['date address from', 'time'], ['date address to', 'time'], ['monthly rental', 'number'], ['other details', 'text']]
-- Table: students in detention
columns : [['student id', 'number'], ['detention id', 'number'], ['incident id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `Find the start and end dates of behavior incidents of students with last name "Fahey".` to a syntactically-correct PostgreSQL query.
| SELECT T1.date_incident_start , date_incident_end FROM Behavior_Incident AS T1 JOIN Students AS T2 ON T1.student_id = T2.student_id WHERE T2.last_name = "Fahey" |
Find the start and end dates of detentions of teachers with last name "Schultz". |
-- Language PostgreSQL
-- Tables:
-- Table: reference address types
columns : [['address type code', 'text'], ['address type description', 'text']]
-- Table: reference detention type
columns : [['detention type code', 'text'], ['detention type description', 'text']]
-- Table: reference incident type
columns : [['incident type code', 'text'], ['incident type description', 'text']]
-- Table: addresses
columns : [['address id', 'number'], ['line 1', 'text'], ['line 2', 'text'], ['line 3', 'text'], ['city', 'text'], ['zip postcode', 'text'], ['state province county', 'text'], ['country', 'text'], ['other address details', 'text']]
-- Table: students
columns : [['student id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['date first rental', 'time'], ['date left university', 'time'], ['other student details', 'text']]
-- Table: teachers
columns : [['teacher id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['gender', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['other details', 'text']]
-- Table: assessment notes
columns : [['notes id', 'number'], ['student id', 'number'], ['teacher id', 'number'], ['date of notes', 'time'], ['text of notes', 'text'], ['other details', 'text']]
-- Table: behavior incident
columns : [['incident id', 'number'], ['incident type code', 'text'], ['student id', 'number'], ['date incident start', 'time'], ['date incident end', 'time'], ['incident summary', 'text'], ['recommendations', 'text'], ['other details', 'text']]
-- Table: detention
columns : [['detention id', 'number'], ['detention type code', 'text'], ['teacher id', 'number'], ['datetime detention start', 'time'], ['datetime detention end', 'time'], ['detention summary', 'text'], ['other details', 'text']]
-- Table: student addresses
columns : [['student id', 'number'], ['address id', 'number'], ['date address from', 'time'], ['date address to', 'time'], ['monthly rental', 'number'], ['other details', 'text']]
-- Table: students in detention
columns : [['student id', 'number'], ['detention id', 'number'], ['incident id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `Find the start and end dates of detentions of teachers with last name "Schultz".` to a syntactically-correct PostgreSQL query.
| SELECT T1.datetime_detention_start , datetime_detention_end FROM Detention AS T1 JOIN Teachers AS T2 ON T1.teacher_id = T2.teacher_id WHERE T2.last_name = "Schultz" |
What are the id and zip code of the address with the highest monthly rental? |
-- Language PostgreSQL
-- Tables:
-- Table: reference address types
columns : [['address type code', 'text'], ['address type description', 'text']]
-- Table: reference detention type
columns : [['detention type code', 'text'], ['detention type description', 'text']]
-- Table: reference incident type
columns : [['incident type code', 'text'], ['incident type description', 'text']]
-- Table: addresses
columns : [['address id', 'number'], ['line 1', 'text'], ['line 2', 'text'], ['line 3', 'text'], ['city', 'text'], ['zip postcode', 'text'], ['state province county', 'text'], ['country', 'text'], ['other address details', 'text']]
-- Table: students
columns : [['student id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['date first rental', 'time'], ['date left university', 'time'], ['other student details', 'text']]
-- Table: teachers
columns : [['teacher id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['gender', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['other details', 'text']]
-- Table: assessment notes
columns : [['notes id', 'number'], ['student id', 'number'], ['teacher id', 'number'], ['date of notes', 'time'], ['text of notes', 'text'], ['other details', 'text']]
-- Table: behavior incident
columns : [['incident id', 'number'], ['incident type code', 'text'], ['student id', 'number'], ['date incident start', 'time'], ['date incident end', 'time'], ['incident summary', 'text'], ['recommendations', 'text'], ['other details', 'text']]
-- Table: detention
columns : [['detention id', 'number'], ['detention type code', 'text'], ['teacher id', 'number'], ['datetime detention start', 'time'], ['datetime detention end', 'time'], ['detention summary', 'text'], ['other details', 'text']]
-- Table: student addresses
columns : [['student id', 'number'], ['address id', 'number'], ['date address from', 'time'], ['date address to', 'time'], ['monthly rental', 'number'], ['other details', 'text']]
-- Table: students in detention
columns : [['student id', 'number'], ['detention id', 'number'], ['incident id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `What are the id and zip code of the address with the highest monthly rental?` to a syntactically-correct PostgreSQL query.
| SELECT T2.address_id , T1.zip_postcode FROM Addresses AS T1 JOIN Student_Addresses AS T2 ON T1.address_id = T2.address_id ORDER BY monthly_rental DESC LIMIT 1 |
What is the cell phone number of the student whose address has the lowest monthly rental? |
-- Language PostgreSQL
-- Tables:
-- Table: reference address types
columns : [['address type code', 'text'], ['address type description', 'text']]
-- Table: reference detention type
columns : [['detention type code', 'text'], ['detention type description', 'text']]
-- Table: reference incident type
columns : [['incident type code', 'text'], ['incident type description', 'text']]
-- Table: addresses
columns : [['address id', 'number'], ['line 1', 'text'], ['line 2', 'text'], ['line 3', 'text'], ['city', 'text'], ['zip postcode', 'text'], ['state province county', 'text'], ['country', 'text'], ['other address details', 'text']]
-- Table: students
columns : [['student id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['date first rental', 'time'], ['date left university', 'time'], ['other student details', 'text']]
-- Table: teachers
columns : [['teacher id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['gender', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['other details', 'text']]
-- Table: assessment notes
columns : [['notes id', 'number'], ['student id', 'number'], ['teacher id', 'number'], ['date of notes', 'time'], ['text of notes', 'text'], ['other details', 'text']]
-- Table: behavior incident
columns : [['incident id', 'number'], ['incident type code', 'text'], ['student id', 'number'], ['date incident start', 'time'], ['date incident end', 'time'], ['incident summary', 'text'], ['recommendations', 'text'], ['other details', 'text']]
-- Table: detention
columns : [['detention id', 'number'], ['detention type code', 'text'], ['teacher id', 'number'], ['datetime detention start', 'time'], ['datetime detention end', 'time'], ['detention summary', 'text'], ['other details', 'text']]
-- Table: student addresses
columns : [['student id', 'number'], ['address id', 'number'], ['date address from', 'time'], ['date address to', 'time'], ['monthly rental', 'number'], ['other details', 'text']]
-- Table: students in detention
columns : [['student id', 'number'], ['detention id', 'number'], ['incident id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `What is the cell phone number of the student whose address has the lowest monthly rental?` to a syntactically-correct PostgreSQL query.
| SELECT T2.cell_mobile_number FROM Student_Addresses AS T1 JOIN Students AS T2 ON T1.student_id = T2.student_id ORDER BY T1.monthly_rental ASC LIMIT 1 |
What are the monthly rentals of student addresses in Texas state? |
-- Language PostgreSQL
-- Tables:
-- Table: reference address types
columns : [['address type code', 'text'], ['address type description', 'text']]
-- Table: reference detention type
columns : [['detention type code', 'text'], ['detention type description', 'text']]
-- Table: reference incident type
columns : [['incident type code', 'text'], ['incident type description', 'text']]
-- Table: addresses
columns : [['address id', 'number'], ['line 1', 'text'], ['line 2', 'text'], ['line 3', 'text'], ['city', 'text'], ['zip postcode', 'text'], ['state province county', 'text'], ['country', 'text'], ['other address details', 'text']]
-- Table: students
columns : [['student id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['date first rental', 'time'], ['date left university', 'time'], ['other student details', 'text']]
-- Table: teachers
columns : [['teacher id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['gender', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['other details', 'text']]
-- Table: assessment notes
columns : [['notes id', 'number'], ['student id', 'number'], ['teacher id', 'number'], ['date of notes', 'time'], ['text of notes', 'text'], ['other details', 'text']]
-- Table: behavior incident
columns : [['incident id', 'number'], ['incident type code', 'text'], ['student id', 'number'], ['date incident start', 'time'], ['date incident end', 'time'], ['incident summary', 'text'], ['recommendations', 'text'], ['other details', 'text']]
-- Table: detention
columns : [['detention id', 'number'], ['detention type code', 'text'], ['teacher id', 'number'], ['datetime detention start', 'time'], ['datetime detention end', 'time'], ['detention summary', 'text'], ['other details', 'text']]
-- Table: student addresses
columns : [['student id', 'number'], ['address id', 'number'], ['date address from', 'time'], ['date address to', 'time'], ['monthly rental', 'number'], ['other details', 'text']]
-- Table: students in detention
columns : [['student id', 'number'], ['detention id', 'number'], ['incident id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `What are the monthly rentals of student addresses in Texas state?` to a syntactically-correct PostgreSQL query.
| SELECT T2.monthly_rental FROM Addresses AS T1 JOIN Student_Addresses AS T2 ON T1.address_id = T2.address_id WHERE T1.state_province_county = "Texas" |
What are the first names and last names of students with address in Wisconsin state? |
-- Language PostgreSQL
-- Tables:
-- Table: reference address types
columns : [['address type code', 'text'], ['address type description', 'text']]
-- Table: reference detention type
columns : [['detention type code', 'text'], ['detention type description', 'text']]
-- Table: reference incident type
columns : [['incident type code', 'text'], ['incident type description', 'text']]
-- Table: addresses
columns : [['address id', 'number'], ['line 1', 'text'], ['line 2', 'text'], ['line 3', 'text'], ['city', 'text'], ['zip postcode', 'text'], ['state province county', 'text'], ['country', 'text'], ['other address details', 'text']]
-- Table: students
columns : [['student id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['date first rental', 'time'], ['date left university', 'time'], ['other student details', 'text']]
-- Table: teachers
columns : [['teacher id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['gender', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['other details', 'text']]
-- Table: assessment notes
columns : [['notes id', 'number'], ['student id', 'number'], ['teacher id', 'number'], ['date of notes', 'time'], ['text of notes', 'text'], ['other details', 'text']]
-- Table: behavior incident
columns : [['incident id', 'number'], ['incident type code', 'text'], ['student id', 'number'], ['date incident start', 'time'], ['date incident end', 'time'], ['incident summary', 'text'], ['recommendations', 'text'], ['other details', 'text']]
-- Table: detention
columns : [['detention id', 'number'], ['detention type code', 'text'], ['teacher id', 'number'], ['datetime detention start', 'time'], ['datetime detention end', 'time'], ['detention summary', 'text'], ['other details', 'text']]
-- Table: student addresses
columns : [['student id', 'number'], ['address id', 'number'], ['date address from', 'time'], ['date address to', 'time'], ['monthly rental', 'number'], ['other details', 'text']]
-- Table: students in detention
columns : [['student id', 'number'], ['detention id', 'number'], ['incident id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `What are the first names and last names of students with address in Wisconsin state?` to a syntactically-correct PostgreSQL query.
| SELECT T2.first_name , T2.last_name FROM Addresses AS T1 JOIN Students AS T2 ON T1.address_id = T2.address_id WHERE T1.state_province_county = "Wisconsin" |
What are the line 1 and average monthly rentals of all student addresses? |
-- Language PostgreSQL
-- Tables:
-- Table: reference address types
columns : [['address type code', 'text'], ['address type description', 'text']]
-- Table: reference detention type
columns : [['detention type code', 'text'], ['detention type description', 'text']]
-- Table: reference incident type
columns : [['incident type code', 'text'], ['incident type description', 'text']]
-- Table: addresses
columns : [['address id', 'number'], ['line 1', 'text'], ['line 2', 'text'], ['line 3', 'text'], ['city', 'text'], ['zip postcode', 'text'], ['state province county', 'text'], ['country', 'text'], ['other address details', 'text']]
-- Table: students
columns : [['student id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['date first rental', 'time'], ['date left university', 'time'], ['other student details', 'text']]
-- Table: teachers
columns : [['teacher id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['gender', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['other details', 'text']]
-- Table: assessment notes
columns : [['notes id', 'number'], ['student id', 'number'], ['teacher id', 'number'], ['date of notes', 'time'], ['text of notes', 'text'], ['other details', 'text']]
-- Table: behavior incident
columns : [['incident id', 'number'], ['incident type code', 'text'], ['student id', 'number'], ['date incident start', 'time'], ['date incident end', 'time'], ['incident summary', 'text'], ['recommendations', 'text'], ['other details', 'text']]
-- Table: detention
columns : [['detention id', 'number'], ['detention type code', 'text'], ['teacher id', 'number'], ['datetime detention start', 'time'], ['datetime detention end', 'time'], ['detention summary', 'text'], ['other details', 'text']]
-- Table: student addresses
columns : [['student id', 'number'], ['address id', 'number'], ['date address from', 'time'], ['date address to', 'time'], ['monthly rental', 'number'], ['other details', 'text']]
-- Table: students in detention
columns : [['student id', 'number'], ['detention id', 'number'], ['incident id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `What are the line 1 and average monthly rentals of all student addresses?` to a syntactically-correct PostgreSQL query.
| SELECT T1.line_1 , avg(T2.monthly_rental) FROM Addresses AS T1 JOIN Student_Addresses AS T2 ON T1.address_id = T2.address_id GROUP BY T2.address_id |
What is the zip code of the address where the teacher with first name "Lyla" lives? |
-- Language PostgreSQL
-- Tables:
-- Table: reference address types
columns : [['address type code', 'text'], ['address type description', 'text']]
-- Table: reference detention type
columns : [['detention type code', 'text'], ['detention type description', 'text']]
-- Table: reference incident type
columns : [['incident type code', 'text'], ['incident type description', 'text']]
-- Table: addresses
columns : [['address id', 'number'], ['line 1', 'text'], ['line 2', 'text'], ['line 3', 'text'], ['city', 'text'], ['zip postcode', 'text'], ['state province county', 'text'], ['country', 'text'], ['other address details', 'text']]
-- Table: students
columns : [['student id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['date first rental', 'time'], ['date left university', 'time'], ['other student details', 'text']]
-- Table: teachers
columns : [['teacher id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['gender', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['other details', 'text']]
-- Table: assessment notes
columns : [['notes id', 'number'], ['student id', 'number'], ['teacher id', 'number'], ['date of notes', 'time'], ['text of notes', 'text'], ['other details', 'text']]
-- Table: behavior incident
columns : [['incident id', 'number'], ['incident type code', 'text'], ['student id', 'number'], ['date incident start', 'time'], ['date incident end', 'time'], ['incident summary', 'text'], ['recommendations', 'text'], ['other details', 'text']]
-- Table: detention
columns : [['detention id', 'number'], ['detention type code', 'text'], ['teacher id', 'number'], ['datetime detention start', 'time'], ['datetime detention end', 'time'], ['detention summary', 'text'], ['other details', 'text']]
-- Table: student addresses
columns : [['student id', 'number'], ['address id', 'number'], ['date address from', 'time'], ['date address to', 'time'], ['monthly rental', 'number'], ['other details', 'text']]
-- Table: students in detention
columns : [['student id', 'number'], ['detention id', 'number'], ['incident id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `What is the zip code of the address where the teacher with first name "Lyla" lives?` to a syntactically-correct PostgreSQL query.
| SELECT T1.zip_postcode FROM Addresses AS T1 JOIN Teachers AS T2 ON T1.address_id = T2.address_id WHERE T2.first_name = "Lyla" |
What are the email addresses of teachers whose address has zip code "918"? |
-- Language PostgreSQL
-- Tables:
-- Table: reference address types
columns : [['address type code', 'text'], ['address type description', 'text']]
-- Table: reference detention type
columns : [['detention type code', 'text'], ['detention type description', 'text']]
-- Table: reference incident type
columns : [['incident type code', 'text'], ['incident type description', 'text']]
-- Table: addresses
columns : [['address id', 'number'], ['line 1', 'text'], ['line 2', 'text'], ['line 3', 'text'], ['city', 'text'], ['zip postcode', 'text'], ['state province county', 'text'], ['country', 'text'], ['other address details', 'text']]
-- Table: students
columns : [['student id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['date first rental', 'time'], ['date left university', 'time'], ['other student details', 'text']]
-- Table: teachers
columns : [['teacher id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['gender', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['other details', 'text']]
-- Table: assessment notes
columns : [['notes id', 'number'], ['student id', 'number'], ['teacher id', 'number'], ['date of notes', 'time'], ['text of notes', 'text'], ['other details', 'text']]
-- Table: behavior incident
columns : [['incident id', 'number'], ['incident type code', 'text'], ['student id', 'number'], ['date incident start', 'time'], ['date incident end', 'time'], ['incident summary', 'text'], ['recommendations', 'text'], ['other details', 'text']]
-- Table: detention
columns : [['detention id', 'number'], ['detention type code', 'text'], ['teacher id', 'number'], ['datetime detention start', 'time'], ['datetime detention end', 'time'], ['detention summary', 'text'], ['other details', 'text']]
-- Table: student addresses
columns : [['student id', 'number'], ['address id', 'number'], ['date address from', 'time'], ['date address to', 'time'], ['monthly rental', 'number'], ['other details', 'text']]
-- Table: students in detention
columns : [['student id', 'number'], ['detention id', 'number'], ['incident id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `What are the email addresses of teachers whose address has zip code "918"?` to a syntactically-correct PostgreSQL query.
| SELECT T2.email_address FROM Addresses AS T1 JOIN Teachers AS T2 ON T1.address_id = T2.address_id WHERE T1.zip_postcode = "918" |
How many students are not involved in any behavior incident? |
-- Language PostgreSQL
-- Tables:
-- Table: reference address types
columns : [['address type code', 'text'], ['address type description', 'text']]
-- Table: reference detention type
columns : [['detention type code', 'text'], ['detention type description', 'text']]
-- Table: reference incident type
columns : [['incident type code', 'text'], ['incident type description', 'text']]
-- Table: addresses
columns : [['address id', 'number'], ['line 1', 'text'], ['line 2', 'text'], ['line 3', 'text'], ['city', 'text'], ['zip postcode', 'text'], ['state province county', 'text'], ['country', 'text'], ['other address details', 'text']]
-- Table: students
columns : [['student id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['date first rental', 'time'], ['date left university', 'time'], ['other student details', 'text']]
-- Table: teachers
columns : [['teacher id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['gender', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['other details', 'text']]
-- Table: assessment notes
columns : [['notes id', 'number'], ['student id', 'number'], ['teacher id', 'number'], ['date of notes', 'time'], ['text of notes', 'text'], ['other details', 'text']]
-- Table: behavior incident
columns : [['incident id', 'number'], ['incident type code', 'text'], ['student id', 'number'], ['date incident start', 'time'], ['date incident end', 'time'], ['incident summary', 'text'], ['recommendations', 'text'], ['other details', 'text']]
-- Table: detention
columns : [['detention id', 'number'], ['detention type code', 'text'], ['teacher id', 'number'], ['datetime detention start', 'time'], ['datetime detention end', 'time'], ['detention summary', 'text'], ['other details', 'text']]
-- Table: student addresses
columns : [['student id', 'number'], ['address id', 'number'], ['date address from', 'time'], ['date address to', 'time'], ['monthly rental', 'number'], ['other details', 'text']]
-- Table: students in detention
columns : [['student id', 'number'], ['detention id', 'number'], ['incident id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `How many students are not involved in any behavior incident?` to a syntactically-correct PostgreSQL query.
| SELECT count(*) FROM STUDENTS WHERE student_id NOT IN ( SELECT student_id FROM Behavior_Incident ) |
Find the last names of teachers who are not involved in any detention. |
-- Language PostgreSQL
-- Tables:
-- Table: reference address types
columns : [['address type code', 'text'], ['address type description', 'text']]
-- Table: reference detention type
columns : [['detention type code', 'text'], ['detention type description', 'text']]
-- Table: reference incident type
columns : [['incident type code', 'text'], ['incident type description', 'text']]
-- Table: addresses
columns : [['address id', 'number'], ['line 1', 'text'], ['line 2', 'text'], ['line 3', 'text'], ['city', 'text'], ['zip postcode', 'text'], ['state province county', 'text'], ['country', 'text'], ['other address details', 'text']]
-- Table: students
columns : [['student id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['date first rental', 'time'], ['date left university', 'time'], ['other student details', 'text']]
-- Table: teachers
columns : [['teacher id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['gender', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['other details', 'text']]
-- Table: assessment notes
columns : [['notes id', 'number'], ['student id', 'number'], ['teacher id', 'number'], ['date of notes', 'time'], ['text of notes', 'text'], ['other details', 'text']]
-- Table: behavior incident
columns : [['incident id', 'number'], ['incident type code', 'text'], ['student id', 'number'], ['date incident start', 'time'], ['date incident end', 'time'], ['incident summary', 'text'], ['recommendations', 'text'], ['other details', 'text']]
-- Table: detention
columns : [['detention id', 'number'], ['detention type code', 'text'], ['teacher id', 'number'], ['datetime detention start', 'time'], ['datetime detention end', 'time'], ['detention summary', 'text'], ['other details', 'text']]
-- Table: student addresses
columns : [['student id', 'number'], ['address id', 'number'], ['date address from', 'time'], ['date address to', 'time'], ['monthly rental', 'number'], ['other details', 'text']]
-- Table: students in detention
columns : [['student id', 'number'], ['detention id', 'number'], ['incident id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `Find the last names of teachers who are not involved in any detention.` to a syntactically-correct PostgreSQL query.
| SELECT last_name FROM Teachers EXCEPT SELECT T1.last_name FROM Teachers AS T1 JOIN Detention AS T2 ON T1.teacher_id = T2.teacher_id |
What are the line 1 of addresses shared by some students and some teachers? |
-- Language PostgreSQL
-- Tables:
-- Table: reference address types
columns : [['address type code', 'text'], ['address type description', 'text']]
-- Table: reference detention type
columns : [['detention type code', 'text'], ['detention type description', 'text']]
-- Table: reference incident type
columns : [['incident type code', 'text'], ['incident type description', 'text']]
-- Table: addresses
columns : [['address id', 'number'], ['line 1', 'text'], ['line 2', 'text'], ['line 3', 'text'], ['city', 'text'], ['zip postcode', 'text'], ['state province county', 'text'], ['country', 'text'], ['other address details', 'text']]
-- Table: students
columns : [['student id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['date first rental', 'time'], ['date left university', 'time'], ['other student details', 'text']]
-- Table: teachers
columns : [['teacher id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['gender', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['other details', 'text']]
-- Table: assessment notes
columns : [['notes id', 'number'], ['student id', 'number'], ['teacher id', 'number'], ['date of notes', 'time'], ['text of notes', 'text'], ['other details', 'text']]
-- Table: behavior incident
columns : [['incident id', 'number'], ['incident type code', 'text'], ['student id', 'number'], ['date incident start', 'time'], ['date incident end', 'time'], ['incident summary', 'text'], ['recommendations', 'text'], ['other details', 'text']]
-- Table: detention
columns : [['detention id', 'number'], ['detention type code', 'text'], ['teacher id', 'number'], ['datetime detention start', 'time'], ['datetime detention end', 'time'], ['detention summary', 'text'], ['other details', 'text']]
-- Table: student addresses
columns : [['student id', 'number'], ['address id', 'number'], ['date address from', 'time'], ['date address to', 'time'], ['monthly rental', 'number'], ['other details', 'text']]
-- Table: students in detention
columns : [['student id', 'number'], ['detention id', 'number'], ['incident id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `What are the line 1 of addresses shared by some students and some teachers?` to a syntactically-correct PostgreSQL query.
| SELECT T1.line_1 FROM Addresses AS T1 JOIN Students AS T2 ON T1.address_id = T2.address_id INTERSECT SELECT T1.line_1 FROM Addresses AS T1 JOIN Teachers AS T2 ON T1.address_id = T2.address_id |
Which assets have 2 parts and have less than 2 fault logs? List the asset id and detail. |
-- Language PostgreSQL
-- Tables:
-- Table: third party companies
columns : [['company id', 'number'], ['company type', 'text'], ['company name', 'text'], ['company address', 'text'], ['other company details', 'text']]
-- Table: maintenance contracts
columns : [['maintenance contract id', 'number'], ['maintenance contract company id', 'number'], ['contract start date', 'time'], ['contract end date', 'time'], ['other contract details', 'text']]
-- Table: parts
columns : [['part id', 'number'], ['part name', 'text'], ['chargeable yn', 'text'], ['chargeable amount', 'text'], ['other part details', 'text']]
-- Table: skills
columns : [['skill id', 'number'], ['skill code', 'text'], ['skill description', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff name', 'text'], ['gender', 'text'], ['other staff details', 'text']]
-- Table: assets
columns : [['asset id', 'number'], ['maintenance contract id', 'number'], ['supplier company id', 'number'], ['asset details', 'text'], ['asset make', 'text'], ['asset model', 'text'], ['asset acquired date', 'time'], ['asset disposed date', 'time'], ['other asset details', 'text']]
-- Table: asset parts
columns : [['asset id', 'number'], ['part id', 'number']]
-- Table: maintenance engineers
columns : [['engineer id', 'number'], ['company id', 'number'], ['first name', 'text'], ['last name', 'text'], ['other details', 'text']]
-- Table: engineer skills
columns : [['engineer id', 'number'], ['skill id', 'number']]
-- Table: fault log
columns : [['fault log entry id', 'number'], ['asset id', 'number'], ['recorded by staff id', 'number'], ['fault log entry datetime', 'time'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: engineer visits
columns : [['engineer visit id', 'number'], ['contact staff id', 'number'], ['engineer id', 'number'], ['fault log entry id', 'number'], ['fault status', 'text'], ['visit start datetime', 'time'], ['visit end datetime', 'time'], ['other visit details', 'text']]
-- Table: part faults
columns : [['part fault id', 'number'], ['part id', 'number'], ['fault short name', 'text'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: fault log parts
columns : [['fault log entry id', 'number'], ['part fault id', 'number'], ['fault status', 'text']]
-- Table: skills required to fix
columns : [['part fault id', 'number'], ['skill id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `Which assets have 2 parts and have less than 2 fault logs? List the asset id and detail.` to a syntactically-correct PostgreSQL query.
| SELECT T1.asset_id , T1.asset_details FROM Assets AS T1 JOIN Asset_Parts AS T2 ON T1.asset_id = T2.asset_id GROUP BY T1.asset_id HAVING count(*) = 2 INTERSECT SELECT T1.asset_id , T1.asset_details FROM Assets AS T1 JOIN Fault_Log AS T2 ON T1.asset_id = T2.asset_id GROUP BY T1.asset_id HAVING count(*) < 2 |
How many assets does each maintenance contract contain? List the number and the contract id. |
-- Language PostgreSQL
-- Tables:
-- Table: third party companies
columns : [['company id', 'number'], ['company type', 'text'], ['company name', 'text'], ['company address', 'text'], ['other company details', 'text']]
-- Table: maintenance contracts
columns : [['maintenance contract id', 'number'], ['maintenance contract company id', 'number'], ['contract start date', 'time'], ['contract end date', 'time'], ['other contract details', 'text']]
-- Table: parts
columns : [['part id', 'number'], ['part name', 'text'], ['chargeable yn', 'text'], ['chargeable amount', 'text'], ['other part details', 'text']]
-- Table: skills
columns : [['skill id', 'number'], ['skill code', 'text'], ['skill description', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff name', 'text'], ['gender', 'text'], ['other staff details', 'text']]
-- Table: assets
columns : [['asset id', 'number'], ['maintenance contract id', 'number'], ['supplier company id', 'number'], ['asset details', 'text'], ['asset make', 'text'], ['asset model', 'text'], ['asset acquired date', 'time'], ['asset disposed date', 'time'], ['other asset details', 'text']]
-- Table: asset parts
columns : [['asset id', 'number'], ['part id', 'number']]
-- Table: maintenance engineers
columns : [['engineer id', 'number'], ['company id', 'number'], ['first name', 'text'], ['last name', 'text'], ['other details', 'text']]
-- Table: engineer skills
columns : [['engineer id', 'number'], ['skill id', 'number']]
-- Table: fault log
columns : [['fault log entry id', 'number'], ['asset id', 'number'], ['recorded by staff id', 'number'], ['fault log entry datetime', 'time'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: engineer visits
columns : [['engineer visit id', 'number'], ['contact staff id', 'number'], ['engineer id', 'number'], ['fault log entry id', 'number'], ['fault status', 'text'], ['visit start datetime', 'time'], ['visit end datetime', 'time'], ['other visit details', 'text']]
-- Table: part faults
columns : [['part fault id', 'number'], ['part id', 'number'], ['fault short name', 'text'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: fault log parts
columns : [['fault log entry id', 'number'], ['part fault id', 'number'], ['fault status', 'text']]
-- Table: skills required to fix
columns : [['part fault id', 'number'], ['skill id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `How many assets does each maintenance contract contain? List the number and the contract id.` to a syntactically-correct PostgreSQL query.
| SELECT count(*) , T1.maintenance_contract_id FROM Maintenance_Contracts AS T1 JOIN Assets AS T2 ON T1.maintenance_contract_id = T2.maintenance_contract_id GROUP BY T1.maintenance_contract_id |
How many assets does each third party company supply? List the count and the company id. |
-- Language PostgreSQL
-- Tables:
-- Table: third party companies
columns : [['company id', 'number'], ['company type', 'text'], ['company name', 'text'], ['company address', 'text'], ['other company details', 'text']]
-- Table: maintenance contracts
columns : [['maintenance contract id', 'number'], ['maintenance contract company id', 'number'], ['contract start date', 'time'], ['contract end date', 'time'], ['other contract details', 'text']]
-- Table: parts
columns : [['part id', 'number'], ['part name', 'text'], ['chargeable yn', 'text'], ['chargeable amount', 'text'], ['other part details', 'text']]
-- Table: skills
columns : [['skill id', 'number'], ['skill code', 'text'], ['skill description', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff name', 'text'], ['gender', 'text'], ['other staff details', 'text']]
-- Table: assets
columns : [['asset id', 'number'], ['maintenance contract id', 'number'], ['supplier company id', 'number'], ['asset details', 'text'], ['asset make', 'text'], ['asset model', 'text'], ['asset acquired date', 'time'], ['asset disposed date', 'time'], ['other asset details', 'text']]
-- Table: asset parts
columns : [['asset id', 'number'], ['part id', 'number']]
-- Table: maintenance engineers
columns : [['engineer id', 'number'], ['company id', 'number'], ['first name', 'text'], ['last name', 'text'], ['other details', 'text']]
-- Table: engineer skills
columns : [['engineer id', 'number'], ['skill id', 'number']]
-- Table: fault log
columns : [['fault log entry id', 'number'], ['asset id', 'number'], ['recorded by staff id', 'number'], ['fault log entry datetime', 'time'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: engineer visits
columns : [['engineer visit id', 'number'], ['contact staff id', 'number'], ['engineer id', 'number'], ['fault log entry id', 'number'], ['fault status', 'text'], ['visit start datetime', 'time'], ['visit end datetime', 'time'], ['other visit details', 'text']]
-- Table: part faults
columns : [['part fault id', 'number'], ['part id', 'number'], ['fault short name', 'text'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: fault log parts
columns : [['fault log entry id', 'number'], ['part fault id', 'number'], ['fault status', 'text']]
-- Table: skills required to fix
columns : [['part fault id', 'number'], ['skill id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `How many assets does each third party company supply? List the count and the company id.` to a syntactically-correct PostgreSQL query.
| SELECT count(*) , T1.company_id FROM Third_Party_Companies AS T1 JOIN Assets AS T2 ON T1.company_id = T2.supplier_company_id GROUP BY T1.company_id |
Which third party companies have at least 2 maintenance engineers or have at least 2 maintenance contracts? List the company id and name. |
-- Language PostgreSQL
-- Tables:
-- Table: third party companies
columns : [['company id', 'number'], ['company type', 'text'], ['company name', 'text'], ['company address', 'text'], ['other company details', 'text']]
-- Table: maintenance contracts
columns : [['maintenance contract id', 'number'], ['maintenance contract company id', 'number'], ['contract start date', 'time'], ['contract end date', 'time'], ['other contract details', 'text']]
-- Table: parts
columns : [['part id', 'number'], ['part name', 'text'], ['chargeable yn', 'text'], ['chargeable amount', 'text'], ['other part details', 'text']]
-- Table: skills
columns : [['skill id', 'number'], ['skill code', 'text'], ['skill description', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff name', 'text'], ['gender', 'text'], ['other staff details', 'text']]
-- Table: assets
columns : [['asset id', 'number'], ['maintenance contract id', 'number'], ['supplier company id', 'number'], ['asset details', 'text'], ['asset make', 'text'], ['asset model', 'text'], ['asset acquired date', 'time'], ['asset disposed date', 'time'], ['other asset details', 'text']]
-- Table: asset parts
columns : [['asset id', 'number'], ['part id', 'number']]
-- Table: maintenance engineers
columns : [['engineer id', 'number'], ['company id', 'number'], ['first name', 'text'], ['last name', 'text'], ['other details', 'text']]
-- Table: engineer skills
columns : [['engineer id', 'number'], ['skill id', 'number']]
-- Table: fault log
columns : [['fault log entry id', 'number'], ['asset id', 'number'], ['recorded by staff id', 'number'], ['fault log entry datetime', 'time'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: engineer visits
columns : [['engineer visit id', 'number'], ['contact staff id', 'number'], ['engineer id', 'number'], ['fault log entry id', 'number'], ['fault status', 'text'], ['visit start datetime', 'time'], ['visit end datetime', 'time'], ['other visit details', 'text']]
-- Table: part faults
columns : [['part fault id', 'number'], ['part id', 'number'], ['fault short name', 'text'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: fault log parts
columns : [['fault log entry id', 'number'], ['part fault id', 'number'], ['fault status', 'text']]
-- Table: skills required to fix
columns : [['part fault id', 'number'], ['skill id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `Which third party companies have at least 2 maintenance engineers or have at least 2 maintenance contracts? List the company id and name.` to a syntactically-correct PostgreSQL query.
| SELECT T1.company_id , T1.company_name FROM Third_Party_Companies AS T1 JOIN Maintenance_Engineers AS T2 ON T1.company_id = T2.company_id GROUP BY T1.company_id HAVING count(*) >= 2 UNION SELECT T3.company_id , T3.company_name FROM Third_Party_Companies AS T3 JOIN Maintenance_Contracts AS T4 ON T3.company_id = T4.maintenance_contract_company_id GROUP BY T3.company_id HAVING count(*) >= 2 |
What is the name and id of the staff who recorded the fault log but has not contacted any visiting engineers? |
-- Language PostgreSQL
-- Tables:
-- Table: third party companies
columns : [['company id', 'number'], ['company type', 'text'], ['company name', 'text'], ['company address', 'text'], ['other company details', 'text']]
-- Table: maintenance contracts
columns : [['maintenance contract id', 'number'], ['maintenance contract company id', 'number'], ['contract start date', 'time'], ['contract end date', 'time'], ['other contract details', 'text']]
-- Table: parts
columns : [['part id', 'number'], ['part name', 'text'], ['chargeable yn', 'text'], ['chargeable amount', 'text'], ['other part details', 'text']]
-- Table: skills
columns : [['skill id', 'number'], ['skill code', 'text'], ['skill description', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff name', 'text'], ['gender', 'text'], ['other staff details', 'text']]
-- Table: assets
columns : [['asset id', 'number'], ['maintenance contract id', 'number'], ['supplier company id', 'number'], ['asset details', 'text'], ['asset make', 'text'], ['asset model', 'text'], ['asset acquired date', 'time'], ['asset disposed date', 'time'], ['other asset details', 'text']]
-- Table: asset parts
columns : [['asset id', 'number'], ['part id', 'number']]
-- Table: maintenance engineers
columns : [['engineer id', 'number'], ['company id', 'number'], ['first name', 'text'], ['last name', 'text'], ['other details', 'text']]
-- Table: engineer skills
columns : [['engineer id', 'number'], ['skill id', 'number']]
-- Table: fault log
columns : [['fault log entry id', 'number'], ['asset id', 'number'], ['recorded by staff id', 'number'], ['fault log entry datetime', 'time'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: engineer visits
columns : [['engineer visit id', 'number'], ['contact staff id', 'number'], ['engineer id', 'number'], ['fault log entry id', 'number'], ['fault status', 'text'], ['visit start datetime', 'time'], ['visit end datetime', 'time'], ['other visit details', 'text']]
-- Table: part faults
columns : [['part fault id', 'number'], ['part id', 'number'], ['fault short name', 'text'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: fault log parts
columns : [['fault log entry id', 'number'], ['part fault id', 'number'], ['fault status', 'text']]
-- Table: skills required to fix
columns : [['part fault id', 'number'], ['skill id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `What is the name and id of the staff who recorded the fault log but has not contacted any visiting engineers?` to a syntactically-correct PostgreSQL query.
| SELECT T1.staff_name , T1.staff_id FROM Staff AS T1 JOIN Fault_Log AS T2 ON T1.staff_id = T2.recorded_by_staff_id EXCEPT SELECT T3.staff_name , T3.staff_id FROM Staff AS T3 JOIN Engineer_Visits AS T4 ON T3.staff_id = T4.contact_staff_id |
Which engineer has visited the most times? Show the engineer id, first name and last name. |
-- Language PostgreSQL
-- Tables:
-- Table: third party companies
columns : [['company id', 'number'], ['company type', 'text'], ['company name', 'text'], ['company address', 'text'], ['other company details', 'text']]
-- Table: maintenance contracts
columns : [['maintenance contract id', 'number'], ['maintenance contract company id', 'number'], ['contract start date', 'time'], ['contract end date', 'time'], ['other contract details', 'text']]
-- Table: parts
columns : [['part id', 'number'], ['part name', 'text'], ['chargeable yn', 'text'], ['chargeable amount', 'text'], ['other part details', 'text']]
-- Table: skills
columns : [['skill id', 'number'], ['skill code', 'text'], ['skill description', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff name', 'text'], ['gender', 'text'], ['other staff details', 'text']]
-- Table: assets
columns : [['asset id', 'number'], ['maintenance contract id', 'number'], ['supplier company id', 'number'], ['asset details', 'text'], ['asset make', 'text'], ['asset model', 'text'], ['asset acquired date', 'time'], ['asset disposed date', 'time'], ['other asset details', 'text']]
-- Table: asset parts
columns : [['asset id', 'number'], ['part id', 'number']]
-- Table: maintenance engineers
columns : [['engineer id', 'number'], ['company id', 'number'], ['first name', 'text'], ['last name', 'text'], ['other details', 'text']]
-- Table: engineer skills
columns : [['engineer id', 'number'], ['skill id', 'number']]
-- Table: fault log
columns : [['fault log entry id', 'number'], ['asset id', 'number'], ['recorded by staff id', 'number'], ['fault log entry datetime', 'time'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: engineer visits
columns : [['engineer visit id', 'number'], ['contact staff id', 'number'], ['engineer id', 'number'], ['fault log entry id', 'number'], ['fault status', 'text'], ['visit start datetime', 'time'], ['visit end datetime', 'time'], ['other visit details', 'text']]
-- Table: part faults
columns : [['part fault id', 'number'], ['part id', 'number'], ['fault short name', 'text'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: fault log parts
columns : [['fault log entry id', 'number'], ['part fault id', 'number'], ['fault status', 'text']]
-- Table: skills required to fix
columns : [['part fault id', 'number'], ['skill id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `Which engineer has visited the most times? Show the engineer id, first name and last name.` to a syntactically-correct PostgreSQL query.
| SELECT T1.engineer_id , T1.first_name , T1.last_name FROM Maintenance_Engineers AS T1 JOIN Engineer_Visits AS T2 GROUP BY T1.engineer_id ORDER BY count(*) DESC LIMIT 1 |
Which parts have more than 2 faults? Show the part name and id. |
-- Language PostgreSQL
-- Tables:
-- Table: third party companies
columns : [['company id', 'number'], ['company type', 'text'], ['company name', 'text'], ['company address', 'text'], ['other company details', 'text']]
-- Table: maintenance contracts
columns : [['maintenance contract id', 'number'], ['maintenance contract company id', 'number'], ['contract start date', 'time'], ['contract end date', 'time'], ['other contract details', 'text']]
-- Table: parts
columns : [['part id', 'number'], ['part name', 'text'], ['chargeable yn', 'text'], ['chargeable amount', 'text'], ['other part details', 'text']]
-- Table: skills
columns : [['skill id', 'number'], ['skill code', 'text'], ['skill description', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff name', 'text'], ['gender', 'text'], ['other staff details', 'text']]
-- Table: assets
columns : [['asset id', 'number'], ['maintenance contract id', 'number'], ['supplier company id', 'number'], ['asset details', 'text'], ['asset make', 'text'], ['asset model', 'text'], ['asset acquired date', 'time'], ['asset disposed date', 'time'], ['other asset details', 'text']]
-- Table: asset parts
columns : [['asset id', 'number'], ['part id', 'number']]
-- Table: maintenance engineers
columns : [['engineer id', 'number'], ['company id', 'number'], ['first name', 'text'], ['last name', 'text'], ['other details', 'text']]
-- Table: engineer skills
columns : [['engineer id', 'number'], ['skill id', 'number']]
-- Table: fault log
columns : [['fault log entry id', 'number'], ['asset id', 'number'], ['recorded by staff id', 'number'], ['fault log entry datetime', 'time'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: engineer visits
columns : [['engineer visit id', 'number'], ['contact staff id', 'number'], ['engineer id', 'number'], ['fault log entry id', 'number'], ['fault status', 'text'], ['visit start datetime', 'time'], ['visit end datetime', 'time'], ['other visit details', 'text']]
-- Table: part faults
columns : [['part fault id', 'number'], ['part id', 'number'], ['fault short name', 'text'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: fault log parts
columns : [['fault log entry id', 'number'], ['part fault id', 'number'], ['fault status', 'text']]
-- Table: skills required to fix
columns : [['part fault id', 'number'], ['skill id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `Which parts have more than 2 faults? Show the part name and id.` to a syntactically-correct PostgreSQL query.
| SELECT T1.part_name , T1.part_id FROM Parts AS T1 JOIN Part_Faults AS T2 ON T1.part_id = T2.part_id GROUP BY T1.part_id HAVING count(*) > 2 |
List all every engineer's first name, last name, details and coresponding skill description. |
-- Language PostgreSQL
-- Tables:
-- Table: third party companies
columns : [['company id', 'number'], ['company type', 'text'], ['company name', 'text'], ['company address', 'text'], ['other company details', 'text']]
-- Table: maintenance contracts
columns : [['maintenance contract id', 'number'], ['maintenance contract company id', 'number'], ['contract start date', 'time'], ['contract end date', 'time'], ['other contract details', 'text']]
-- Table: parts
columns : [['part id', 'number'], ['part name', 'text'], ['chargeable yn', 'text'], ['chargeable amount', 'text'], ['other part details', 'text']]
-- Table: skills
columns : [['skill id', 'number'], ['skill code', 'text'], ['skill description', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff name', 'text'], ['gender', 'text'], ['other staff details', 'text']]
-- Table: assets
columns : [['asset id', 'number'], ['maintenance contract id', 'number'], ['supplier company id', 'number'], ['asset details', 'text'], ['asset make', 'text'], ['asset model', 'text'], ['asset acquired date', 'time'], ['asset disposed date', 'time'], ['other asset details', 'text']]
-- Table: asset parts
columns : [['asset id', 'number'], ['part id', 'number']]
-- Table: maintenance engineers
columns : [['engineer id', 'number'], ['company id', 'number'], ['first name', 'text'], ['last name', 'text'], ['other details', 'text']]
-- Table: engineer skills
columns : [['engineer id', 'number'], ['skill id', 'number']]
-- Table: fault log
columns : [['fault log entry id', 'number'], ['asset id', 'number'], ['recorded by staff id', 'number'], ['fault log entry datetime', 'time'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: engineer visits
columns : [['engineer visit id', 'number'], ['contact staff id', 'number'], ['engineer id', 'number'], ['fault log entry id', 'number'], ['fault status', 'text'], ['visit start datetime', 'time'], ['visit end datetime', 'time'], ['other visit details', 'text']]
-- Table: part faults
columns : [['part fault id', 'number'], ['part id', 'number'], ['fault short name', 'text'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: fault log parts
columns : [['fault log entry id', 'number'], ['part fault id', 'number'], ['fault status', 'text']]
-- Table: skills required to fix
columns : [['part fault id', 'number'], ['skill id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `List all every engineer's first name, last name, details and coresponding skill description.` to a syntactically-correct PostgreSQL query.
| SELECT T1.first_name , T1.last_name , T1.other_details , T3.skill_description FROM Maintenance_Engineers AS T1 JOIN Engineer_Skills AS T2 ON T1.engineer_id = T2.engineer_id JOIN Skills AS T3 ON T2.skill_id = T3.skill_id |
For all the faults of different parts, what are all the decriptions of the skills required to fix them? List the name of the faults and the skill description. |
-- Language PostgreSQL
-- Tables:
-- Table: third party companies
columns : [['company id', 'number'], ['company type', 'text'], ['company name', 'text'], ['company address', 'text'], ['other company details', 'text']]
-- Table: maintenance contracts
columns : [['maintenance contract id', 'number'], ['maintenance contract company id', 'number'], ['contract start date', 'time'], ['contract end date', 'time'], ['other contract details', 'text']]
-- Table: parts
columns : [['part id', 'number'], ['part name', 'text'], ['chargeable yn', 'text'], ['chargeable amount', 'text'], ['other part details', 'text']]
-- Table: skills
columns : [['skill id', 'number'], ['skill code', 'text'], ['skill description', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff name', 'text'], ['gender', 'text'], ['other staff details', 'text']]
-- Table: assets
columns : [['asset id', 'number'], ['maintenance contract id', 'number'], ['supplier company id', 'number'], ['asset details', 'text'], ['asset make', 'text'], ['asset model', 'text'], ['asset acquired date', 'time'], ['asset disposed date', 'time'], ['other asset details', 'text']]
-- Table: asset parts
columns : [['asset id', 'number'], ['part id', 'number']]
-- Table: maintenance engineers
columns : [['engineer id', 'number'], ['company id', 'number'], ['first name', 'text'], ['last name', 'text'], ['other details', 'text']]
-- Table: engineer skills
columns : [['engineer id', 'number'], ['skill id', 'number']]
-- Table: fault log
columns : [['fault log entry id', 'number'], ['asset id', 'number'], ['recorded by staff id', 'number'], ['fault log entry datetime', 'time'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: engineer visits
columns : [['engineer visit id', 'number'], ['contact staff id', 'number'], ['engineer id', 'number'], ['fault log entry id', 'number'], ['fault status', 'text'], ['visit start datetime', 'time'], ['visit end datetime', 'time'], ['other visit details', 'text']]
-- Table: part faults
columns : [['part fault id', 'number'], ['part id', 'number'], ['fault short name', 'text'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: fault log parts
columns : [['fault log entry id', 'number'], ['part fault id', 'number'], ['fault status', 'text']]
-- Table: skills required to fix
columns : [['part fault id', 'number'], ['skill id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `For all the faults of different parts, what are all the decriptions of the skills required to fix them? List the name of the faults and the skill description.` to a syntactically-correct PostgreSQL query.
| SELECT T1.fault_short_name , T3.skill_description FROM Part_Faults AS T1 JOIN Skills_Required_To_Fix AS T2 ON T1.part_fault_id = T2.part_fault_id JOIN Skills AS T3 ON T2.skill_id = T3.skill_id |
How many assets can each parts be used in? List the part name and the number. |
-- Language PostgreSQL
-- Tables:
-- Table: third party companies
columns : [['company id', 'number'], ['company type', 'text'], ['company name', 'text'], ['company address', 'text'], ['other company details', 'text']]
-- Table: maintenance contracts
columns : [['maintenance contract id', 'number'], ['maintenance contract company id', 'number'], ['contract start date', 'time'], ['contract end date', 'time'], ['other contract details', 'text']]
-- Table: parts
columns : [['part id', 'number'], ['part name', 'text'], ['chargeable yn', 'text'], ['chargeable amount', 'text'], ['other part details', 'text']]
-- Table: skills
columns : [['skill id', 'number'], ['skill code', 'text'], ['skill description', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff name', 'text'], ['gender', 'text'], ['other staff details', 'text']]
-- Table: assets
columns : [['asset id', 'number'], ['maintenance contract id', 'number'], ['supplier company id', 'number'], ['asset details', 'text'], ['asset make', 'text'], ['asset model', 'text'], ['asset acquired date', 'time'], ['asset disposed date', 'time'], ['other asset details', 'text']]
-- Table: asset parts
columns : [['asset id', 'number'], ['part id', 'number']]
-- Table: maintenance engineers
columns : [['engineer id', 'number'], ['company id', 'number'], ['first name', 'text'], ['last name', 'text'], ['other details', 'text']]
-- Table: engineer skills
columns : [['engineer id', 'number'], ['skill id', 'number']]
-- Table: fault log
columns : [['fault log entry id', 'number'], ['asset id', 'number'], ['recorded by staff id', 'number'], ['fault log entry datetime', 'time'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: engineer visits
columns : [['engineer visit id', 'number'], ['contact staff id', 'number'], ['engineer id', 'number'], ['fault log entry id', 'number'], ['fault status', 'text'], ['visit start datetime', 'time'], ['visit end datetime', 'time'], ['other visit details', 'text']]
-- Table: part faults
columns : [['part fault id', 'number'], ['part id', 'number'], ['fault short name', 'text'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: fault log parts
columns : [['fault log entry id', 'number'], ['part fault id', 'number'], ['fault status', 'text']]
-- Table: skills required to fix
columns : [['part fault id', 'number'], ['skill id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `How many assets can each parts be used in? List the part name and the number.` to a syntactically-correct PostgreSQL query.
| SELECT T1.part_name , count(*) FROM Parts AS T1 JOIN Asset_Parts AS T2 ON T1.part_id = T2.part_id GROUP BY T1.part_name |
What are all the fault descriptions and the fault status of all the faults recoreded in the logs? |
-- Language PostgreSQL
-- Tables:
-- Table: third party companies
columns : [['company id', 'number'], ['company type', 'text'], ['company name', 'text'], ['company address', 'text'], ['other company details', 'text']]
-- Table: maintenance contracts
columns : [['maintenance contract id', 'number'], ['maintenance contract company id', 'number'], ['contract start date', 'time'], ['contract end date', 'time'], ['other contract details', 'text']]
-- Table: parts
columns : [['part id', 'number'], ['part name', 'text'], ['chargeable yn', 'text'], ['chargeable amount', 'text'], ['other part details', 'text']]
-- Table: skills
columns : [['skill id', 'number'], ['skill code', 'text'], ['skill description', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff name', 'text'], ['gender', 'text'], ['other staff details', 'text']]
-- Table: assets
columns : [['asset id', 'number'], ['maintenance contract id', 'number'], ['supplier company id', 'number'], ['asset details', 'text'], ['asset make', 'text'], ['asset model', 'text'], ['asset acquired date', 'time'], ['asset disposed date', 'time'], ['other asset details', 'text']]
-- Table: asset parts
columns : [['asset id', 'number'], ['part id', 'number']]
-- Table: maintenance engineers
columns : [['engineer id', 'number'], ['company id', 'number'], ['first name', 'text'], ['last name', 'text'], ['other details', 'text']]
-- Table: engineer skills
columns : [['engineer id', 'number'], ['skill id', 'number']]
-- Table: fault log
columns : [['fault log entry id', 'number'], ['asset id', 'number'], ['recorded by staff id', 'number'], ['fault log entry datetime', 'time'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: engineer visits
columns : [['engineer visit id', 'number'], ['contact staff id', 'number'], ['engineer id', 'number'], ['fault log entry id', 'number'], ['fault status', 'text'], ['visit start datetime', 'time'], ['visit end datetime', 'time'], ['other visit details', 'text']]
-- Table: part faults
columns : [['part fault id', 'number'], ['part id', 'number'], ['fault short name', 'text'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: fault log parts
columns : [['fault log entry id', 'number'], ['part fault id', 'number'], ['fault status', 'text']]
-- Table: skills required to fix
columns : [['part fault id', 'number'], ['skill id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `What are all the fault descriptions and the fault status of all the faults recoreded in the logs?` to a syntactically-correct PostgreSQL query.
| SELECT T1.fault_description , T2.fault_status FROM Fault_Log AS T1 JOIN Fault_Log_Parts AS T2 ON T1.fault_log_entry_id = T2.fault_log_entry_id |
How many engineer visits are required at most for a single fault log? List the number and the log entry id. |
-- Language PostgreSQL
-- Tables:
-- Table: third party companies
columns : [['company id', 'number'], ['company type', 'text'], ['company name', 'text'], ['company address', 'text'], ['other company details', 'text']]
-- Table: maintenance contracts
columns : [['maintenance contract id', 'number'], ['maintenance contract company id', 'number'], ['contract start date', 'time'], ['contract end date', 'time'], ['other contract details', 'text']]
-- Table: parts
columns : [['part id', 'number'], ['part name', 'text'], ['chargeable yn', 'text'], ['chargeable amount', 'text'], ['other part details', 'text']]
-- Table: skills
columns : [['skill id', 'number'], ['skill code', 'text'], ['skill description', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff name', 'text'], ['gender', 'text'], ['other staff details', 'text']]
-- Table: assets
columns : [['asset id', 'number'], ['maintenance contract id', 'number'], ['supplier company id', 'number'], ['asset details', 'text'], ['asset make', 'text'], ['asset model', 'text'], ['asset acquired date', 'time'], ['asset disposed date', 'time'], ['other asset details', 'text']]
-- Table: asset parts
columns : [['asset id', 'number'], ['part id', 'number']]
-- Table: maintenance engineers
columns : [['engineer id', 'number'], ['company id', 'number'], ['first name', 'text'], ['last name', 'text'], ['other details', 'text']]
-- Table: engineer skills
columns : [['engineer id', 'number'], ['skill id', 'number']]
-- Table: fault log
columns : [['fault log entry id', 'number'], ['asset id', 'number'], ['recorded by staff id', 'number'], ['fault log entry datetime', 'time'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: engineer visits
columns : [['engineer visit id', 'number'], ['contact staff id', 'number'], ['engineer id', 'number'], ['fault log entry id', 'number'], ['fault status', 'text'], ['visit start datetime', 'time'], ['visit end datetime', 'time'], ['other visit details', 'text']]
-- Table: part faults
columns : [['part fault id', 'number'], ['part id', 'number'], ['fault short name', 'text'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: fault log parts
columns : [['fault log entry id', 'number'], ['part fault id', 'number'], ['fault status', 'text']]
-- Table: skills required to fix
columns : [['part fault id', 'number'], ['skill id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `How many engineer visits are required at most for a single fault log? List the number and the log entry id.` to a syntactically-correct PostgreSQL query.
| SELECT count(*) , T1.fault_log_entry_id FROM Fault_Log AS T1 JOIN Engineer_Visits AS T2 ON T1.fault_log_entry_id = T2.fault_log_entry_id GROUP BY T1.fault_log_entry_id ORDER BY count(*) DESC LIMIT 1 |
What are all the distinct last names of all the engineers? |
-- Language PostgreSQL
-- Tables:
-- Table: third party companies
columns : [['company id', 'number'], ['company type', 'text'], ['company name', 'text'], ['company address', 'text'], ['other company details', 'text']]
-- Table: maintenance contracts
columns : [['maintenance contract id', 'number'], ['maintenance contract company id', 'number'], ['contract start date', 'time'], ['contract end date', 'time'], ['other contract details', 'text']]
-- Table: parts
columns : [['part id', 'number'], ['part name', 'text'], ['chargeable yn', 'text'], ['chargeable amount', 'text'], ['other part details', 'text']]
-- Table: skills
columns : [['skill id', 'number'], ['skill code', 'text'], ['skill description', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff name', 'text'], ['gender', 'text'], ['other staff details', 'text']]
-- Table: assets
columns : [['asset id', 'number'], ['maintenance contract id', 'number'], ['supplier company id', 'number'], ['asset details', 'text'], ['asset make', 'text'], ['asset model', 'text'], ['asset acquired date', 'time'], ['asset disposed date', 'time'], ['other asset details', 'text']]
-- Table: asset parts
columns : [['asset id', 'number'], ['part id', 'number']]
-- Table: maintenance engineers
columns : [['engineer id', 'number'], ['company id', 'number'], ['first name', 'text'], ['last name', 'text'], ['other details', 'text']]
-- Table: engineer skills
columns : [['engineer id', 'number'], ['skill id', 'number']]
-- Table: fault log
columns : [['fault log entry id', 'number'], ['asset id', 'number'], ['recorded by staff id', 'number'], ['fault log entry datetime', 'time'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: engineer visits
columns : [['engineer visit id', 'number'], ['contact staff id', 'number'], ['engineer id', 'number'], ['fault log entry id', 'number'], ['fault status', 'text'], ['visit start datetime', 'time'], ['visit end datetime', 'time'], ['other visit details', 'text']]
-- Table: part faults
columns : [['part fault id', 'number'], ['part id', 'number'], ['fault short name', 'text'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: fault log parts
columns : [['fault log entry id', 'number'], ['part fault id', 'number'], ['fault status', 'text']]
-- Table: skills required to fix
columns : [['part fault id', 'number'], ['skill id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `What are all the distinct last names of all the engineers?` to a syntactically-correct PostgreSQL query.
| SELECT DISTINCT last_name FROM Maintenance_Engineers |
How many fault status codes are recorded in the fault log parts table? |
-- Language PostgreSQL
-- Tables:
-- Table: third party companies
columns : [['company id', 'number'], ['company type', 'text'], ['company name', 'text'], ['company address', 'text'], ['other company details', 'text']]
-- Table: maintenance contracts
columns : [['maintenance contract id', 'number'], ['maintenance contract company id', 'number'], ['contract start date', 'time'], ['contract end date', 'time'], ['other contract details', 'text']]
-- Table: parts
columns : [['part id', 'number'], ['part name', 'text'], ['chargeable yn', 'text'], ['chargeable amount', 'text'], ['other part details', 'text']]
-- Table: skills
columns : [['skill id', 'number'], ['skill code', 'text'], ['skill description', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff name', 'text'], ['gender', 'text'], ['other staff details', 'text']]
-- Table: assets
columns : [['asset id', 'number'], ['maintenance contract id', 'number'], ['supplier company id', 'number'], ['asset details', 'text'], ['asset make', 'text'], ['asset model', 'text'], ['asset acquired date', 'time'], ['asset disposed date', 'time'], ['other asset details', 'text']]
-- Table: asset parts
columns : [['asset id', 'number'], ['part id', 'number']]
-- Table: maintenance engineers
columns : [['engineer id', 'number'], ['company id', 'number'], ['first name', 'text'], ['last name', 'text'], ['other details', 'text']]
-- Table: engineer skills
columns : [['engineer id', 'number'], ['skill id', 'number']]
-- Table: fault log
columns : [['fault log entry id', 'number'], ['asset id', 'number'], ['recorded by staff id', 'number'], ['fault log entry datetime', 'time'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: engineer visits
columns : [['engineer visit id', 'number'], ['contact staff id', 'number'], ['engineer id', 'number'], ['fault log entry id', 'number'], ['fault status', 'text'], ['visit start datetime', 'time'], ['visit end datetime', 'time'], ['other visit details', 'text']]
-- Table: part faults
columns : [['part fault id', 'number'], ['part id', 'number'], ['fault short name', 'text'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: fault log parts
columns : [['fault log entry id', 'number'], ['part fault id', 'number'], ['fault status', 'text']]
-- Table: skills required to fix
columns : [['part fault id', 'number'], ['skill id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `How many fault status codes are recorded in the fault log parts table?` to a syntactically-correct PostgreSQL query.
| SELECT DISTINCT fault_status FROM Fault_Log_Parts |
Which engineers have never visited to maintain the assets? List the engineer first name and last name. |
-- Language PostgreSQL
-- Tables:
-- Table: third party companies
columns : [['company id', 'number'], ['company type', 'text'], ['company name', 'text'], ['company address', 'text'], ['other company details', 'text']]
-- Table: maintenance contracts
columns : [['maintenance contract id', 'number'], ['maintenance contract company id', 'number'], ['contract start date', 'time'], ['contract end date', 'time'], ['other contract details', 'text']]
-- Table: parts
columns : [['part id', 'number'], ['part name', 'text'], ['chargeable yn', 'text'], ['chargeable amount', 'text'], ['other part details', 'text']]
-- Table: skills
columns : [['skill id', 'number'], ['skill code', 'text'], ['skill description', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff name', 'text'], ['gender', 'text'], ['other staff details', 'text']]
-- Table: assets
columns : [['asset id', 'number'], ['maintenance contract id', 'number'], ['supplier company id', 'number'], ['asset details', 'text'], ['asset make', 'text'], ['asset model', 'text'], ['asset acquired date', 'time'], ['asset disposed date', 'time'], ['other asset details', 'text']]
-- Table: asset parts
columns : [['asset id', 'number'], ['part id', 'number']]
-- Table: maintenance engineers
columns : [['engineer id', 'number'], ['company id', 'number'], ['first name', 'text'], ['last name', 'text'], ['other details', 'text']]
-- Table: engineer skills
columns : [['engineer id', 'number'], ['skill id', 'number']]
-- Table: fault log
columns : [['fault log entry id', 'number'], ['asset id', 'number'], ['recorded by staff id', 'number'], ['fault log entry datetime', 'time'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: engineer visits
columns : [['engineer visit id', 'number'], ['contact staff id', 'number'], ['engineer id', 'number'], ['fault log entry id', 'number'], ['fault status', 'text'], ['visit start datetime', 'time'], ['visit end datetime', 'time'], ['other visit details', 'text']]
-- Table: part faults
columns : [['part fault id', 'number'], ['part id', 'number'], ['fault short name', 'text'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: fault log parts
columns : [['fault log entry id', 'number'], ['part fault id', 'number'], ['fault status', 'text']]
-- Table: skills required to fix
columns : [['part fault id', 'number'], ['skill id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `Which engineers have never visited to maintain the assets? List the engineer first name and last name.` to a syntactically-correct PostgreSQL query.
| SELECT first_name , last_name FROM Maintenance_Engineers WHERE engineer_id NOT IN (SELECT engineer_id FROM Engineer_Visits) |
List the asset id, details, make and model for every asset. |
-- Language PostgreSQL
-- Tables:
-- Table: third party companies
columns : [['company id', 'number'], ['company type', 'text'], ['company name', 'text'], ['company address', 'text'], ['other company details', 'text']]
-- Table: maintenance contracts
columns : [['maintenance contract id', 'number'], ['maintenance contract company id', 'number'], ['contract start date', 'time'], ['contract end date', 'time'], ['other contract details', 'text']]
-- Table: parts
columns : [['part id', 'number'], ['part name', 'text'], ['chargeable yn', 'text'], ['chargeable amount', 'text'], ['other part details', 'text']]
-- Table: skills
columns : [['skill id', 'number'], ['skill code', 'text'], ['skill description', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff name', 'text'], ['gender', 'text'], ['other staff details', 'text']]
-- Table: assets
columns : [['asset id', 'number'], ['maintenance contract id', 'number'], ['supplier company id', 'number'], ['asset details', 'text'], ['asset make', 'text'], ['asset model', 'text'], ['asset acquired date', 'time'], ['asset disposed date', 'time'], ['other asset details', 'text']]
-- Table: asset parts
columns : [['asset id', 'number'], ['part id', 'number']]
-- Table: maintenance engineers
columns : [['engineer id', 'number'], ['company id', 'number'], ['first name', 'text'], ['last name', 'text'], ['other details', 'text']]
-- Table: engineer skills
columns : [['engineer id', 'number'], ['skill id', 'number']]
-- Table: fault log
columns : [['fault log entry id', 'number'], ['asset id', 'number'], ['recorded by staff id', 'number'], ['fault log entry datetime', 'time'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: engineer visits
columns : [['engineer visit id', 'number'], ['contact staff id', 'number'], ['engineer id', 'number'], ['fault log entry id', 'number'], ['fault status', 'text'], ['visit start datetime', 'time'], ['visit end datetime', 'time'], ['other visit details', 'text']]
-- Table: part faults
columns : [['part fault id', 'number'], ['part id', 'number'], ['fault short name', 'text'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: fault log parts
columns : [['fault log entry id', 'number'], ['part fault id', 'number'], ['fault status', 'text']]
-- Table: skills required to fix
columns : [['part fault id', 'number'], ['skill id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `List the asset id, details, make and model for every asset.` to a syntactically-correct PostgreSQL query.
| SELECT asset_id , asset_details , asset_make , asset_model FROM Assets |
When was the first asset acquired? |
-- Language PostgreSQL
-- Tables:
-- Table: third party companies
columns : [['company id', 'number'], ['company type', 'text'], ['company name', 'text'], ['company address', 'text'], ['other company details', 'text']]
-- Table: maintenance contracts
columns : [['maintenance contract id', 'number'], ['maintenance contract company id', 'number'], ['contract start date', 'time'], ['contract end date', 'time'], ['other contract details', 'text']]
-- Table: parts
columns : [['part id', 'number'], ['part name', 'text'], ['chargeable yn', 'text'], ['chargeable amount', 'text'], ['other part details', 'text']]
-- Table: skills
columns : [['skill id', 'number'], ['skill code', 'text'], ['skill description', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff name', 'text'], ['gender', 'text'], ['other staff details', 'text']]
-- Table: assets
columns : [['asset id', 'number'], ['maintenance contract id', 'number'], ['supplier company id', 'number'], ['asset details', 'text'], ['asset make', 'text'], ['asset model', 'text'], ['asset acquired date', 'time'], ['asset disposed date', 'time'], ['other asset details', 'text']]
-- Table: asset parts
columns : [['asset id', 'number'], ['part id', 'number']]
-- Table: maintenance engineers
columns : [['engineer id', 'number'], ['company id', 'number'], ['first name', 'text'], ['last name', 'text'], ['other details', 'text']]
-- Table: engineer skills
columns : [['engineer id', 'number'], ['skill id', 'number']]
-- Table: fault log
columns : [['fault log entry id', 'number'], ['asset id', 'number'], ['recorded by staff id', 'number'], ['fault log entry datetime', 'time'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: engineer visits
columns : [['engineer visit id', 'number'], ['contact staff id', 'number'], ['engineer id', 'number'], ['fault log entry id', 'number'], ['fault status', 'text'], ['visit start datetime', 'time'], ['visit end datetime', 'time'], ['other visit details', 'text']]
-- Table: part faults
columns : [['part fault id', 'number'], ['part id', 'number'], ['fault short name', 'text'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: fault log parts
columns : [['fault log entry id', 'number'], ['part fault id', 'number'], ['fault status', 'text']]
-- Table: skills required to fix
columns : [['part fault id', 'number'], ['skill id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `When was the first asset acquired?` to a syntactically-correct PostgreSQL query.
| SELECT asset_acquired_date FROM Assets ORDER BY asset_acquired_date ASC LIMIT 1 |
Which part fault requires the most number of skills to fix? List part id and name. |
-- Language PostgreSQL
-- Tables:
-- Table: third party companies
columns : [['company id', 'number'], ['company type', 'text'], ['company name', 'text'], ['company address', 'text'], ['other company details', 'text']]
-- Table: maintenance contracts
columns : [['maintenance contract id', 'number'], ['maintenance contract company id', 'number'], ['contract start date', 'time'], ['contract end date', 'time'], ['other contract details', 'text']]
-- Table: parts
columns : [['part id', 'number'], ['part name', 'text'], ['chargeable yn', 'text'], ['chargeable amount', 'text'], ['other part details', 'text']]
-- Table: skills
columns : [['skill id', 'number'], ['skill code', 'text'], ['skill description', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff name', 'text'], ['gender', 'text'], ['other staff details', 'text']]
-- Table: assets
columns : [['asset id', 'number'], ['maintenance contract id', 'number'], ['supplier company id', 'number'], ['asset details', 'text'], ['asset make', 'text'], ['asset model', 'text'], ['asset acquired date', 'time'], ['asset disposed date', 'time'], ['other asset details', 'text']]
-- Table: asset parts
columns : [['asset id', 'number'], ['part id', 'number']]
-- Table: maintenance engineers
columns : [['engineer id', 'number'], ['company id', 'number'], ['first name', 'text'], ['last name', 'text'], ['other details', 'text']]
-- Table: engineer skills
columns : [['engineer id', 'number'], ['skill id', 'number']]
-- Table: fault log
columns : [['fault log entry id', 'number'], ['asset id', 'number'], ['recorded by staff id', 'number'], ['fault log entry datetime', 'time'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: engineer visits
columns : [['engineer visit id', 'number'], ['contact staff id', 'number'], ['engineer id', 'number'], ['fault log entry id', 'number'], ['fault status', 'text'], ['visit start datetime', 'time'], ['visit end datetime', 'time'], ['other visit details', 'text']]
-- Table: part faults
columns : [['part fault id', 'number'], ['part id', 'number'], ['fault short name', 'text'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: fault log parts
columns : [['fault log entry id', 'number'], ['part fault id', 'number'], ['fault status', 'text']]
-- Table: skills required to fix
columns : [['part fault id', 'number'], ['skill id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `Which part fault requires the most number of skills to fix? List part id and name.` to a syntactically-correct PostgreSQL query.
| SELECT T1.part_id , T1.part_name FROM Parts AS T1 JOIN Part_Faults AS T2 ON T1.part_id = T2.part_id JOIN Skills_Required_To_Fix AS T3 ON T2.part_fault_id = T3.part_fault_id GROUP BY T1.part_id ORDER BY count(*) DESC LIMIT 1 |
Which kind of part has the least number of faults? List the part name. |
-- Language PostgreSQL
-- Tables:
-- Table: third party companies
columns : [['company id', 'number'], ['company type', 'text'], ['company name', 'text'], ['company address', 'text'], ['other company details', 'text']]
-- Table: maintenance contracts
columns : [['maintenance contract id', 'number'], ['maintenance contract company id', 'number'], ['contract start date', 'time'], ['contract end date', 'time'], ['other contract details', 'text']]
-- Table: parts
columns : [['part id', 'number'], ['part name', 'text'], ['chargeable yn', 'text'], ['chargeable amount', 'text'], ['other part details', 'text']]
-- Table: skills
columns : [['skill id', 'number'], ['skill code', 'text'], ['skill description', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff name', 'text'], ['gender', 'text'], ['other staff details', 'text']]
-- Table: assets
columns : [['asset id', 'number'], ['maintenance contract id', 'number'], ['supplier company id', 'number'], ['asset details', 'text'], ['asset make', 'text'], ['asset model', 'text'], ['asset acquired date', 'time'], ['asset disposed date', 'time'], ['other asset details', 'text']]
-- Table: asset parts
columns : [['asset id', 'number'], ['part id', 'number']]
-- Table: maintenance engineers
columns : [['engineer id', 'number'], ['company id', 'number'], ['first name', 'text'], ['last name', 'text'], ['other details', 'text']]
-- Table: engineer skills
columns : [['engineer id', 'number'], ['skill id', 'number']]
-- Table: fault log
columns : [['fault log entry id', 'number'], ['asset id', 'number'], ['recorded by staff id', 'number'], ['fault log entry datetime', 'time'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: engineer visits
columns : [['engineer visit id', 'number'], ['contact staff id', 'number'], ['engineer id', 'number'], ['fault log entry id', 'number'], ['fault status', 'text'], ['visit start datetime', 'time'], ['visit end datetime', 'time'], ['other visit details', 'text']]
-- Table: part faults
columns : [['part fault id', 'number'], ['part id', 'number'], ['fault short name', 'text'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: fault log parts
columns : [['fault log entry id', 'number'], ['part fault id', 'number'], ['fault status', 'text']]
-- Table: skills required to fix
columns : [['part fault id', 'number'], ['skill id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `Which kind of part has the least number of faults? List the part name.` to a syntactically-correct PostgreSQL query.
| SELECT T1.part_name FROM Parts AS T1 JOIN Part_Faults AS T2 ON T1.part_id = T2.part_id GROUP BY T1.part_name ORDER BY count(*) ASC LIMIT 1 |
Among those engineers who have visited, which engineer makes the least number of visits? List the engineer id, first name and last name. |
-- Language PostgreSQL
-- Tables:
-- Table: third party companies
columns : [['company id', 'number'], ['company type', 'text'], ['company name', 'text'], ['company address', 'text'], ['other company details', 'text']]
-- Table: maintenance contracts
columns : [['maintenance contract id', 'number'], ['maintenance contract company id', 'number'], ['contract start date', 'time'], ['contract end date', 'time'], ['other contract details', 'text']]
-- Table: parts
columns : [['part id', 'number'], ['part name', 'text'], ['chargeable yn', 'text'], ['chargeable amount', 'text'], ['other part details', 'text']]
-- Table: skills
columns : [['skill id', 'number'], ['skill code', 'text'], ['skill description', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff name', 'text'], ['gender', 'text'], ['other staff details', 'text']]
-- Table: assets
columns : [['asset id', 'number'], ['maintenance contract id', 'number'], ['supplier company id', 'number'], ['asset details', 'text'], ['asset make', 'text'], ['asset model', 'text'], ['asset acquired date', 'time'], ['asset disposed date', 'time'], ['other asset details', 'text']]
-- Table: asset parts
columns : [['asset id', 'number'], ['part id', 'number']]
-- Table: maintenance engineers
columns : [['engineer id', 'number'], ['company id', 'number'], ['first name', 'text'], ['last name', 'text'], ['other details', 'text']]
-- Table: engineer skills
columns : [['engineer id', 'number'], ['skill id', 'number']]
-- Table: fault log
columns : [['fault log entry id', 'number'], ['asset id', 'number'], ['recorded by staff id', 'number'], ['fault log entry datetime', 'time'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: engineer visits
columns : [['engineer visit id', 'number'], ['contact staff id', 'number'], ['engineer id', 'number'], ['fault log entry id', 'number'], ['fault status', 'text'], ['visit start datetime', 'time'], ['visit end datetime', 'time'], ['other visit details', 'text']]
-- Table: part faults
columns : [['part fault id', 'number'], ['part id', 'number'], ['fault short name', 'text'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: fault log parts
columns : [['fault log entry id', 'number'], ['part fault id', 'number'], ['fault status', 'text']]
-- Table: skills required to fix
columns : [['part fault id', 'number'], ['skill id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `Among those engineers who have visited, which engineer makes the least number of visits? List the engineer id, first name and last name.` to a syntactically-correct PostgreSQL query.
| SELECT T1.engineer_id , T1.first_name , T1.last_name FROM Maintenance_Engineers AS T1 JOIN Engineer_Visits AS T2 ON T1.engineer_id = T2.engineer_id GROUP BY T1.engineer_id ORDER BY count(*) ASC LIMIT 1 |
Which staff have contacted which engineers? List the staff name and the engineer first name and last name. |
-- Language PostgreSQL
-- Tables:
-- Table: third party companies
columns : [['company id', 'number'], ['company type', 'text'], ['company name', 'text'], ['company address', 'text'], ['other company details', 'text']]
-- Table: maintenance contracts
columns : [['maintenance contract id', 'number'], ['maintenance contract company id', 'number'], ['contract start date', 'time'], ['contract end date', 'time'], ['other contract details', 'text']]
-- Table: parts
columns : [['part id', 'number'], ['part name', 'text'], ['chargeable yn', 'text'], ['chargeable amount', 'text'], ['other part details', 'text']]
-- Table: skills
columns : [['skill id', 'number'], ['skill code', 'text'], ['skill description', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff name', 'text'], ['gender', 'text'], ['other staff details', 'text']]
-- Table: assets
columns : [['asset id', 'number'], ['maintenance contract id', 'number'], ['supplier company id', 'number'], ['asset details', 'text'], ['asset make', 'text'], ['asset model', 'text'], ['asset acquired date', 'time'], ['asset disposed date', 'time'], ['other asset details', 'text']]
-- Table: asset parts
columns : [['asset id', 'number'], ['part id', 'number']]
-- Table: maintenance engineers
columns : [['engineer id', 'number'], ['company id', 'number'], ['first name', 'text'], ['last name', 'text'], ['other details', 'text']]
-- Table: engineer skills
columns : [['engineer id', 'number'], ['skill id', 'number']]
-- Table: fault log
columns : [['fault log entry id', 'number'], ['asset id', 'number'], ['recorded by staff id', 'number'], ['fault log entry datetime', 'time'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: engineer visits
columns : [['engineer visit id', 'number'], ['contact staff id', 'number'], ['engineer id', 'number'], ['fault log entry id', 'number'], ['fault status', 'text'], ['visit start datetime', 'time'], ['visit end datetime', 'time'], ['other visit details', 'text']]
-- Table: part faults
columns : [['part fault id', 'number'], ['part id', 'number'], ['fault short name', 'text'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: fault log parts
columns : [['fault log entry id', 'number'], ['part fault id', 'number'], ['fault status', 'text']]
-- Table: skills required to fix
columns : [['part fault id', 'number'], ['skill id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `Which staff have contacted which engineers? List the staff name and the engineer first name and last name.` to a syntactically-correct PostgreSQL query.
| SELECT T1.staff_name , T3.first_name , T3.last_name FROM Staff AS T1 JOIN Engineer_Visits AS T2 ON T1.staff_id = T2.contact_staff_id JOIN Maintenance_Engineers AS T3 ON T2.engineer_id = T3.engineer_id |
Which fault log included the most number of faulty parts? List the fault log id, description and record time. |
-- Language PostgreSQL
-- Tables:
-- Table: third party companies
columns : [['company id', 'number'], ['company type', 'text'], ['company name', 'text'], ['company address', 'text'], ['other company details', 'text']]
-- Table: maintenance contracts
columns : [['maintenance contract id', 'number'], ['maintenance contract company id', 'number'], ['contract start date', 'time'], ['contract end date', 'time'], ['other contract details', 'text']]
-- Table: parts
columns : [['part id', 'number'], ['part name', 'text'], ['chargeable yn', 'text'], ['chargeable amount', 'text'], ['other part details', 'text']]
-- Table: skills
columns : [['skill id', 'number'], ['skill code', 'text'], ['skill description', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff name', 'text'], ['gender', 'text'], ['other staff details', 'text']]
-- Table: assets
columns : [['asset id', 'number'], ['maintenance contract id', 'number'], ['supplier company id', 'number'], ['asset details', 'text'], ['asset make', 'text'], ['asset model', 'text'], ['asset acquired date', 'time'], ['asset disposed date', 'time'], ['other asset details', 'text']]
-- Table: asset parts
columns : [['asset id', 'number'], ['part id', 'number']]
-- Table: maintenance engineers
columns : [['engineer id', 'number'], ['company id', 'number'], ['first name', 'text'], ['last name', 'text'], ['other details', 'text']]
-- Table: engineer skills
columns : [['engineer id', 'number'], ['skill id', 'number']]
-- Table: fault log
columns : [['fault log entry id', 'number'], ['asset id', 'number'], ['recorded by staff id', 'number'], ['fault log entry datetime', 'time'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: engineer visits
columns : [['engineer visit id', 'number'], ['contact staff id', 'number'], ['engineer id', 'number'], ['fault log entry id', 'number'], ['fault status', 'text'], ['visit start datetime', 'time'], ['visit end datetime', 'time'], ['other visit details', 'text']]
-- Table: part faults
columns : [['part fault id', 'number'], ['part id', 'number'], ['fault short name', 'text'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: fault log parts
columns : [['fault log entry id', 'number'], ['part fault id', 'number'], ['fault status', 'text']]
-- Table: skills required to fix
columns : [['part fault id', 'number'], ['skill id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `Which fault log included the most number of faulty parts? List the fault log id, description and record time.` to a syntactically-correct PostgreSQL query.
| SELECT T1.fault_log_entry_id , T1.fault_description , T1.fault_log_entry_datetime FROM Fault_Log AS T1 JOIN Fault_Log_Parts AS T2 ON T1.fault_log_entry_id = T2.fault_log_entry_id GROUP BY T1.fault_log_entry_id ORDER BY count(*) DESC LIMIT 1 |
Which skill is used in fixing the most number of faults? List the skill id and description. |
-- Language PostgreSQL
-- Tables:
-- Table: third party companies
columns : [['company id', 'number'], ['company type', 'text'], ['company name', 'text'], ['company address', 'text'], ['other company details', 'text']]
-- Table: maintenance contracts
columns : [['maintenance contract id', 'number'], ['maintenance contract company id', 'number'], ['contract start date', 'time'], ['contract end date', 'time'], ['other contract details', 'text']]
-- Table: parts
columns : [['part id', 'number'], ['part name', 'text'], ['chargeable yn', 'text'], ['chargeable amount', 'text'], ['other part details', 'text']]
-- Table: skills
columns : [['skill id', 'number'], ['skill code', 'text'], ['skill description', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff name', 'text'], ['gender', 'text'], ['other staff details', 'text']]
-- Table: assets
columns : [['asset id', 'number'], ['maintenance contract id', 'number'], ['supplier company id', 'number'], ['asset details', 'text'], ['asset make', 'text'], ['asset model', 'text'], ['asset acquired date', 'time'], ['asset disposed date', 'time'], ['other asset details', 'text']]
-- Table: asset parts
columns : [['asset id', 'number'], ['part id', 'number']]
-- Table: maintenance engineers
columns : [['engineer id', 'number'], ['company id', 'number'], ['first name', 'text'], ['last name', 'text'], ['other details', 'text']]
-- Table: engineer skills
columns : [['engineer id', 'number'], ['skill id', 'number']]
-- Table: fault log
columns : [['fault log entry id', 'number'], ['asset id', 'number'], ['recorded by staff id', 'number'], ['fault log entry datetime', 'time'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: engineer visits
columns : [['engineer visit id', 'number'], ['contact staff id', 'number'], ['engineer id', 'number'], ['fault log entry id', 'number'], ['fault status', 'text'], ['visit start datetime', 'time'], ['visit end datetime', 'time'], ['other visit details', 'text']]
-- Table: part faults
columns : [['part fault id', 'number'], ['part id', 'number'], ['fault short name', 'text'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: fault log parts
columns : [['fault log entry id', 'number'], ['part fault id', 'number'], ['fault status', 'text']]
-- Table: skills required to fix
columns : [['part fault id', 'number'], ['skill id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `Which skill is used in fixing the most number of faults? List the skill id and description.` to a syntactically-correct PostgreSQL query.
| SELECT T1.skill_id , T1.skill_description FROM Skills AS T1 JOIN Skills_Required_To_Fix AS T2 ON T1.skill_id = T2.skill_id GROUP BY T1.skill_id ORDER BY count(*) DESC LIMIT 1 |
What are all the distinct asset models? |
-- Language PostgreSQL
-- Tables:
-- Table: third party companies
columns : [['company id', 'number'], ['company type', 'text'], ['company name', 'text'], ['company address', 'text'], ['other company details', 'text']]
-- Table: maintenance contracts
columns : [['maintenance contract id', 'number'], ['maintenance contract company id', 'number'], ['contract start date', 'time'], ['contract end date', 'time'], ['other contract details', 'text']]
-- Table: parts
columns : [['part id', 'number'], ['part name', 'text'], ['chargeable yn', 'text'], ['chargeable amount', 'text'], ['other part details', 'text']]
-- Table: skills
columns : [['skill id', 'number'], ['skill code', 'text'], ['skill description', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff name', 'text'], ['gender', 'text'], ['other staff details', 'text']]
-- Table: assets
columns : [['asset id', 'number'], ['maintenance contract id', 'number'], ['supplier company id', 'number'], ['asset details', 'text'], ['asset make', 'text'], ['asset model', 'text'], ['asset acquired date', 'time'], ['asset disposed date', 'time'], ['other asset details', 'text']]
-- Table: asset parts
columns : [['asset id', 'number'], ['part id', 'number']]
-- Table: maintenance engineers
columns : [['engineer id', 'number'], ['company id', 'number'], ['first name', 'text'], ['last name', 'text'], ['other details', 'text']]
-- Table: engineer skills
columns : [['engineer id', 'number'], ['skill id', 'number']]
-- Table: fault log
columns : [['fault log entry id', 'number'], ['asset id', 'number'], ['recorded by staff id', 'number'], ['fault log entry datetime', 'time'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: engineer visits
columns : [['engineer visit id', 'number'], ['contact staff id', 'number'], ['engineer id', 'number'], ['fault log entry id', 'number'], ['fault status', 'text'], ['visit start datetime', 'time'], ['visit end datetime', 'time'], ['other visit details', 'text']]
-- Table: part faults
columns : [['part fault id', 'number'], ['part id', 'number'], ['fault short name', 'text'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: fault log parts
columns : [['fault log entry id', 'number'], ['part fault id', 'number'], ['fault status', 'text']]
-- Table: skills required to fix
columns : [['part fault id', 'number'], ['skill id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `What are all the distinct asset models?` to a syntactically-correct PostgreSQL query.
| SELECT DISTINCT asset_model FROM Assets |
List the all the assets make, model, details by the disposed date ascendingly. |
-- Language PostgreSQL
-- Tables:
-- Table: third party companies
columns : [['company id', 'number'], ['company type', 'text'], ['company name', 'text'], ['company address', 'text'], ['other company details', 'text']]
-- Table: maintenance contracts
columns : [['maintenance contract id', 'number'], ['maintenance contract company id', 'number'], ['contract start date', 'time'], ['contract end date', 'time'], ['other contract details', 'text']]
-- Table: parts
columns : [['part id', 'number'], ['part name', 'text'], ['chargeable yn', 'text'], ['chargeable amount', 'text'], ['other part details', 'text']]
-- Table: skills
columns : [['skill id', 'number'], ['skill code', 'text'], ['skill description', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff name', 'text'], ['gender', 'text'], ['other staff details', 'text']]
-- Table: assets
columns : [['asset id', 'number'], ['maintenance contract id', 'number'], ['supplier company id', 'number'], ['asset details', 'text'], ['asset make', 'text'], ['asset model', 'text'], ['asset acquired date', 'time'], ['asset disposed date', 'time'], ['other asset details', 'text']]
-- Table: asset parts
columns : [['asset id', 'number'], ['part id', 'number']]
-- Table: maintenance engineers
columns : [['engineer id', 'number'], ['company id', 'number'], ['first name', 'text'], ['last name', 'text'], ['other details', 'text']]
-- Table: engineer skills
columns : [['engineer id', 'number'], ['skill id', 'number']]
-- Table: fault log
columns : [['fault log entry id', 'number'], ['asset id', 'number'], ['recorded by staff id', 'number'], ['fault log entry datetime', 'time'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: engineer visits
columns : [['engineer visit id', 'number'], ['contact staff id', 'number'], ['engineer id', 'number'], ['fault log entry id', 'number'], ['fault status', 'text'], ['visit start datetime', 'time'], ['visit end datetime', 'time'], ['other visit details', 'text']]
-- Table: part faults
columns : [['part fault id', 'number'], ['part id', 'number'], ['fault short name', 'text'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: fault log parts
columns : [['fault log entry id', 'number'], ['part fault id', 'number'], ['fault status', 'text']]
-- Table: skills required to fix
columns : [['part fault id', 'number'], ['skill id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `List the all the assets make, model, details by the disposed date ascendingly.` to a syntactically-correct PostgreSQL query.
| SELECT asset_make , asset_model , asset_details FROM Assets ORDER BY asset_disposed_date ASC |
Which part has the least chargeable amount? List the part id and amount. |
-- Language PostgreSQL
-- Tables:
-- Table: third party companies
columns : [['company id', 'number'], ['company type', 'text'], ['company name', 'text'], ['company address', 'text'], ['other company details', 'text']]
-- Table: maintenance contracts
columns : [['maintenance contract id', 'number'], ['maintenance contract company id', 'number'], ['contract start date', 'time'], ['contract end date', 'time'], ['other contract details', 'text']]
-- Table: parts
columns : [['part id', 'number'], ['part name', 'text'], ['chargeable yn', 'text'], ['chargeable amount', 'text'], ['other part details', 'text']]
-- Table: skills
columns : [['skill id', 'number'], ['skill code', 'text'], ['skill description', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff name', 'text'], ['gender', 'text'], ['other staff details', 'text']]
-- Table: assets
columns : [['asset id', 'number'], ['maintenance contract id', 'number'], ['supplier company id', 'number'], ['asset details', 'text'], ['asset make', 'text'], ['asset model', 'text'], ['asset acquired date', 'time'], ['asset disposed date', 'time'], ['other asset details', 'text']]
-- Table: asset parts
columns : [['asset id', 'number'], ['part id', 'number']]
-- Table: maintenance engineers
columns : [['engineer id', 'number'], ['company id', 'number'], ['first name', 'text'], ['last name', 'text'], ['other details', 'text']]
-- Table: engineer skills
columns : [['engineer id', 'number'], ['skill id', 'number']]
-- Table: fault log
columns : [['fault log entry id', 'number'], ['asset id', 'number'], ['recorded by staff id', 'number'], ['fault log entry datetime', 'time'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: engineer visits
columns : [['engineer visit id', 'number'], ['contact staff id', 'number'], ['engineer id', 'number'], ['fault log entry id', 'number'], ['fault status', 'text'], ['visit start datetime', 'time'], ['visit end datetime', 'time'], ['other visit details', 'text']]
-- Table: part faults
columns : [['part fault id', 'number'], ['part id', 'number'], ['fault short name', 'text'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: fault log parts
columns : [['fault log entry id', 'number'], ['part fault id', 'number'], ['fault status', 'text']]
-- Table: skills required to fix
columns : [['part fault id', 'number'], ['skill id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `Which part has the least chargeable amount? List the part id and amount.` to a syntactically-correct PostgreSQL query.
| SELECT part_id , chargeable_amount FROM Parts ORDER BY chargeable_amount ASC LIMIT 1 |
Which company started the earliest the maintenance contract? Show the company name. |
-- Language PostgreSQL
-- Tables:
-- Table: third party companies
columns : [['company id', 'number'], ['company type', 'text'], ['company name', 'text'], ['company address', 'text'], ['other company details', 'text']]
-- Table: maintenance contracts
columns : [['maintenance contract id', 'number'], ['maintenance contract company id', 'number'], ['contract start date', 'time'], ['contract end date', 'time'], ['other contract details', 'text']]
-- Table: parts
columns : [['part id', 'number'], ['part name', 'text'], ['chargeable yn', 'text'], ['chargeable amount', 'text'], ['other part details', 'text']]
-- Table: skills
columns : [['skill id', 'number'], ['skill code', 'text'], ['skill description', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff name', 'text'], ['gender', 'text'], ['other staff details', 'text']]
-- Table: assets
columns : [['asset id', 'number'], ['maintenance contract id', 'number'], ['supplier company id', 'number'], ['asset details', 'text'], ['asset make', 'text'], ['asset model', 'text'], ['asset acquired date', 'time'], ['asset disposed date', 'time'], ['other asset details', 'text']]
-- Table: asset parts
columns : [['asset id', 'number'], ['part id', 'number']]
-- Table: maintenance engineers
columns : [['engineer id', 'number'], ['company id', 'number'], ['first name', 'text'], ['last name', 'text'], ['other details', 'text']]
-- Table: engineer skills
columns : [['engineer id', 'number'], ['skill id', 'number']]
-- Table: fault log
columns : [['fault log entry id', 'number'], ['asset id', 'number'], ['recorded by staff id', 'number'], ['fault log entry datetime', 'time'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: engineer visits
columns : [['engineer visit id', 'number'], ['contact staff id', 'number'], ['engineer id', 'number'], ['fault log entry id', 'number'], ['fault status', 'text'], ['visit start datetime', 'time'], ['visit end datetime', 'time'], ['other visit details', 'text']]
-- Table: part faults
columns : [['part fault id', 'number'], ['part id', 'number'], ['fault short name', 'text'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: fault log parts
columns : [['fault log entry id', 'number'], ['part fault id', 'number'], ['fault status', 'text']]
-- Table: skills required to fix
columns : [['part fault id', 'number'], ['skill id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `Which company started the earliest the maintenance contract? Show the company name.` to a syntactically-correct PostgreSQL query.
| SELECT T1.company_name FROM Third_Party_Companies AS T1 JOIN Maintenance_Contracts AS T2 ON T1.company_id = T2.maintenance_contract_company_id ORDER BY T2.contract_start_date ASC LIMIT 1 |
What is the description of the type of the company who concluded its contracts most recently? |
-- Language PostgreSQL
-- Tables:
-- Table: third party companies
columns : [['company id', 'number'], ['company type', 'text'], ['company name', 'text'], ['company address', 'text'], ['other company details', 'text']]
-- Table: maintenance contracts
columns : [['maintenance contract id', 'number'], ['maintenance contract company id', 'number'], ['contract start date', 'time'], ['contract end date', 'time'], ['other contract details', 'text']]
-- Table: parts
columns : [['part id', 'number'], ['part name', 'text'], ['chargeable yn', 'text'], ['chargeable amount', 'text'], ['other part details', 'text']]
-- Table: skills
columns : [['skill id', 'number'], ['skill code', 'text'], ['skill description', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff name', 'text'], ['gender', 'text'], ['other staff details', 'text']]
-- Table: assets
columns : [['asset id', 'number'], ['maintenance contract id', 'number'], ['supplier company id', 'number'], ['asset details', 'text'], ['asset make', 'text'], ['asset model', 'text'], ['asset acquired date', 'time'], ['asset disposed date', 'time'], ['other asset details', 'text']]
-- Table: asset parts
columns : [['asset id', 'number'], ['part id', 'number']]
-- Table: maintenance engineers
columns : [['engineer id', 'number'], ['company id', 'number'], ['first name', 'text'], ['last name', 'text'], ['other details', 'text']]
-- Table: engineer skills
columns : [['engineer id', 'number'], ['skill id', 'number']]
-- Table: fault log
columns : [['fault log entry id', 'number'], ['asset id', 'number'], ['recorded by staff id', 'number'], ['fault log entry datetime', 'time'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: engineer visits
columns : [['engineer visit id', 'number'], ['contact staff id', 'number'], ['engineer id', 'number'], ['fault log entry id', 'number'], ['fault status', 'text'], ['visit start datetime', 'time'], ['visit end datetime', 'time'], ['other visit details', 'text']]
-- Table: part faults
columns : [['part fault id', 'number'], ['part id', 'number'], ['fault short name', 'text'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: fault log parts
columns : [['fault log entry id', 'number'], ['part fault id', 'number'], ['fault status', 'text']]
-- Table: skills required to fix
columns : [['part fault id', 'number'], ['skill id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `What is the description of the type of the company who concluded its contracts most recently?` to a syntactically-correct PostgreSQL query.
| SELECT T1.company_name FROM Third_Party_Companies AS T1 JOIN Maintenance_Contracts AS T2 ON T1.company_id = T2.maintenance_contract_company_id JOIN Ref_Company_Types AS T3 ON T1.company_type_code = T3.company_type_code ORDER BY T2.contract_end_date DESC LIMIT 1 |
Which gender makes up the majority of the staff? |
-- Language PostgreSQL
-- Tables:
-- Table: third party companies
columns : [['company id', 'number'], ['company type', 'text'], ['company name', 'text'], ['company address', 'text'], ['other company details', 'text']]
-- Table: maintenance contracts
columns : [['maintenance contract id', 'number'], ['maintenance contract company id', 'number'], ['contract start date', 'time'], ['contract end date', 'time'], ['other contract details', 'text']]
-- Table: parts
columns : [['part id', 'number'], ['part name', 'text'], ['chargeable yn', 'text'], ['chargeable amount', 'text'], ['other part details', 'text']]
-- Table: skills
columns : [['skill id', 'number'], ['skill code', 'text'], ['skill description', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff name', 'text'], ['gender', 'text'], ['other staff details', 'text']]
-- Table: assets
columns : [['asset id', 'number'], ['maintenance contract id', 'number'], ['supplier company id', 'number'], ['asset details', 'text'], ['asset make', 'text'], ['asset model', 'text'], ['asset acquired date', 'time'], ['asset disposed date', 'time'], ['other asset details', 'text']]
-- Table: asset parts
columns : [['asset id', 'number'], ['part id', 'number']]
-- Table: maintenance engineers
columns : [['engineer id', 'number'], ['company id', 'number'], ['first name', 'text'], ['last name', 'text'], ['other details', 'text']]
-- Table: engineer skills
columns : [['engineer id', 'number'], ['skill id', 'number']]
-- Table: fault log
columns : [['fault log entry id', 'number'], ['asset id', 'number'], ['recorded by staff id', 'number'], ['fault log entry datetime', 'time'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: engineer visits
columns : [['engineer visit id', 'number'], ['contact staff id', 'number'], ['engineer id', 'number'], ['fault log entry id', 'number'], ['fault status', 'text'], ['visit start datetime', 'time'], ['visit end datetime', 'time'], ['other visit details', 'text']]
-- Table: part faults
columns : [['part fault id', 'number'], ['part id', 'number'], ['fault short name', 'text'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: fault log parts
columns : [['fault log entry id', 'number'], ['part fault id', 'number'], ['fault status', 'text']]
-- Table: skills required to fix
columns : [['part fault id', 'number'], ['skill id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `Which gender makes up the majority of the staff?` to a syntactically-correct PostgreSQL query.
| SELECT gender FROM staff GROUP BY gender ORDER BY count(*) DESC LIMIT 1 |
How many engineers did each staff contact? List both the contact staff name and number of engineers contacted. |
-- Language PostgreSQL
-- Tables:
-- Table: third party companies
columns : [['company id', 'number'], ['company type', 'text'], ['company name', 'text'], ['company address', 'text'], ['other company details', 'text']]
-- Table: maintenance contracts
columns : [['maintenance contract id', 'number'], ['maintenance contract company id', 'number'], ['contract start date', 'time'], ['contract end date', 'time'], ['other contract details', 'text']]
-- Table: parts
columns : [['part id', 'number'], ['part name', 'text'], ['chargeable yn', 'text'], ['chargeable amount', 'text'], ['other part details', 'text']]
-- Table: skills
columns : [['skill id', 'number'], ['skill code', 'text'], ['skill description', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff name', 'text'], ['gender', 'text'], ['other staff details', 'text']]
-- Table: assets
columns : [['asset id', 'number'], ['maintenance contract id', 'number'], ['supplier company id', 'number'], ['asset details', 'text'], ['asset make', 'text'], ['asset model', 'text'], ['asset acquired date', 'time'], ['asset disposed date', 'time'], ['other asset details', 'text']]
-- Table: asset parts
columns : [['asset id', 'number'], ['part id', 'number']]
-- Table: maintenance engineers
columns : [['engineer id', 'number'], ['company id', 'number'], ['first name', 'text'], ['last name', 'text'], ['other details', 'text']]
-- Table: engineer skills
columns : [['engineer id', 'number'], ['skill id', 'number']]
-- Table: fault log
columns : [['fault log entry id', 'number'], ['asset id', 'number'], ['recorded by staff id', 'number'], ['fault log entry datetime', 'time'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: engineer visits
columns : [['engineer visit id', 'number'], ['contact staff id', 'number'], ['engineer id', 'number'], ['fault log entry id', 'number'], ['fault status', 'text'], ['visit start datetime', 'time'], ['visit end datetime', 'time'], ['other visit details', 'text']]
-- Table: part faults
columns : [['part fault id', 'number'], ['part id', 'number'], ['fault short name', 'text'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: fault log parts
columns : [['fault log entry id', 'number'], ['part fault id', 'number'], ['fault status', 'text']]
-- Table: skills required to fix
columns : [['part fault id', 'number'], ['skill id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `How many engineers did each staff contact? List both the contact staff name and number of engineers contacted.` to a syntactically-correct PostgreSQL query.
| SELECT T1.staff_name , count(*) FROM Staff AS T1 JOIN Engineer_Visits AS T2 ON T1.staff_id = T2.contact_staff_id GROUP BY T1.staff_name |
Which assets did not incur any fault log? List the asset model. |
-- Language PostgreSQL
-- Tables:
-- Table: third party companies
columns : [['company id', 'number'], ['company type', 'text'], ['company name', 'text'], ['company address', 'text'], ['other company details', 'text']]
-- Table: maintenance contracts
columns : [['maintenance contract id', 'number'], ['maintenance contract company id', 'number'], ['contract start date', 'time'], ['contract end date', 'time'], ['other contract details', 'text']]
-- Table: parts
columns : [['part id', 'number'], ['part name', 'text'], ['chargeable yn', 'text'], ['chargeable amount', 'text'], ['other part details', 'text']]
-- Table: skills
columns : [['skill id', 'number'], ['skill code', 'text'], ['skill description', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff name', 'text'], ['gender', 'text'], ['other staff details', 'text']]
-- Table: assets
columns : [['asset id', 'number'], ['maintenance contract id', 'number'], ['supplier company id', 'number'], ['asset details', 'text'], ['asset make', 'text'], ['asset model', 'text'], ['asset acquired date', 'time'], ['asset disposed date', 'time'], ['other asset details', 'text']]
-- Table: asset parts
columns : [['asset id', 'number'], ['part id', 'number']]
-- Table: maintenance engineers
columns : [['engineer id', 'number'], ['company id', 'number'], ['first name', 'text'], ['last name', 'text'], ['other details', 'text']]
-- Table: engineer skills
columns : [['engineer id', 'number'], ['skill id', 'number']]
-- Table: fault log
columns : [['fault log entry id', 'number'], ['asset id', 'number'], ['recorded by staff id', 'number'], ['fault log entry datetime', 'time'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: engineer visits
columns : [['engineer visit id', 'number'], ['contact staff id', 'number'], ['engineer id', 'number'], ['fault log entry id', 'number'], ['fault status', 'text'], ['visit start datetime', 'time'], ['visit end datetime', 'time'], ['other visit details', 'text']]
-- Table: part faults
columns : [['part fault id', 'number'], ['part id', 'number'], ['fault short name', 'text'], ['fault description', 'text'], ['other fault details', 'text']]
-- Table: fault log parts
columns : [['fault log entry id', 'number'], ['part fault id', 'number'], ['fault status', 'text']]
-- Table: skills required to fix
columns : [['part fault id', 'number'], ['skill id', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `Which assets did not incur any fault log? List the asset model.` to a syntactically-correct PostgreSQL query.
| SELECT asset_model FROM Assets WHERE asset_id NOT IN (SELECT asset_id FROM Fault_Log) |
list the local authorities and services provided by all stations. |
-- Language PostgreSQL
-- Tables:
-- Table: train
columns : [['id', 'number'], ['train number', 'number'], ['name', 'text'], ['origin', 'text'], ['destination', 'text'], ['time', 'text'], ['interval', 'text']]
-- Table: station
columns : [['id', 'number'], ['network name', 'text'], ['services', 'text'], ['local authority', 'text']]
-- Table: route
columns : [['train id', 'number'], ['station id', 'number']]
-- Table: weekly weather
columns : [['station id', 'number'], ['day of week', 'text'], ['high temperature', 'number'], ['low temperature', 'number'], ['precipitation', 'number'], ['wind speed mph', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `list the local authorities and services provided by all stations.` to a syntactically-correct PostgreSQL query.
| SELECT local_authority , services FROM station |
show all train numbers and names ordered by their time from early to late. |
-- Language PostgreSQL
-- Tables:
-- Table: train
columns : [['id', 'number'], ['train number', 'number'], ['name', 'text'], ['origin', 'text'], ['destination', 'text'], ['time', 'text'], ['interval', 'text']]
-- Table: station
columns : [['id', 'number'], ['network name', 'text'], ['services', 'text'], ['local authority', 'text']]
-- Table: route
columns : [['train id', 'number'], ['station id', 'number']]
-- Table: weekly weather
columns : [['station id', 'number'], ['day of week', 'text'], ['high temperature', 'number'], ['low temperature', 'number'], ['precipitation', 'number'], ['wind speed mph', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `show all train numbers and names ordered by their time from early to late.` to a syntactically-correct PostgreSQL query.
| SELECT train_number , name FROM train ORDER BY TIME |
Give me the times and numbers of all trains that go to Chennai, ordered by time. |
-- Language PostgreSQL
-- Tables:
-- Table: train
columns : [['id', 'number'], ['train number', 'number'], ['name', 'text'], ['origin', 'text'], ['destination', 'text'], ['time', 'text'], ['interval', 'text']]
-- Table: station
columns : [['id', 'number'], ['network name', 'text'], ['services', 'text'], ['local authority', 'text']]
-- Table: route
columns : [['train id', 'number'], ['station id', 'number']]
-- Table: weekly weather
columns : [['station id', 'number'], ['day of week', 'text'], ['high temperature', 'number'], ['low temperature', 'number'], ['precipitation', 'number'], ['wind speed mph', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `Give me the times and numbers of all trains that go to Chennai, ordered by time.` to a syntactically-correct PostgreSQL query.
| SELECT TIME , train_number FROM train WHERE destination = 'Chennai' ORDER BY TIME |
How many trains have 'Express' in their names? |
-- Language PostgreSQL
-- Tables:
-- Table: train
columns : [['id', 'number'], ['train number', 'number'], ['name', 'text'], ['origin', 'text'], ['destination', 'text'], ['time', 'text'], ['interval', 'text']]
-- Table: station
columns : [['id', 'number'], ['network name', 'text'], ['services', 'text'], ['local authority', 'text']]
-- Table: route
columns : [['train id', 'number'], ['station id', 'number']]
-- Table: weekly weather
columns : [['station id', 'number'], ['day of week', 'text'], ['high temperature', 'number'], ['low temperature', 'number'], ['precipitation', 'number'], ['wind speed mph', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `How many trains have 'Express' in their names?` to a syntactically-correct PostgreSQL query.
| SELECT count(*) FROM train WHERE name LIKE "%Express%" |
Find the number and time of the train that goes from Chennai to Guruvayur. |
-- Language PostgreSQL
-- Tables:
-- Table: train
columns : [['id', 'number'], ['train number', 'number'], ['name', 'text'], ['origin', 'text'], ['destination', 'text'], ['time', 'text'], ['interval', 'text']]
-- Table: station
columns : [['id', 'number'], ['network name', 'text'], ['services', 'text'], ['local authority', 'text']]
-- Table: route
columns : [['train id', 'number'], ['station id', 'number']]
-- Table: weekly weather
columns : [['station id', 'number'], ['day of week', 'text'], ['high temperature', 'number'], ['low temperature', 'number'], ['precipitation', 'number'], ['wind speed mph', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `Find the number and time of the train that goes from Chennai to Guruvayur.` to a syntactically-correct PostgreSQL query.
| SELECT train_number , TIME FROM train WHERE origin = 'Chennai' AND destination = 'Guruvayur' |
Find the number of trains starting from each origin. |
-- Language PostgreSQL
-- Tables:
-- Table: train
columns : [['id', 'number'], ['train number', 'number'], ['name', 'text'], ['origin', 'text'], ['destination', 'text'], ['time', 'text'], ['interval', 'text']]
-- Table: station
columns : [['id', 'number'], ['network name', 'text'], ['services', 'text'], ['local authority', 'text']]
-- Table: route
columns : [['train id', 'number'], ['station id', 'number']]
-- Table: weekly weather
columns : [['station id', 'number'], ['day of week', 'text'], ['high temperature', 'number'], ['low temperature', 'number'], ['precipitation', 'number'], ['wind speed mph', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `Find the number of trains starting from each origin.` to a syntactically-correct PostgreSQL query.
| SELECT origin , count(*) FROM train GROUP BY origin |
Find the name of the train whose route runs through greatest number of stations. |
-- Language PostgreSQL
-- Tables:
-- Table: train
columns : [['id', 'number'], ['train number', 'number'], ['name', 'text'], ['origin', 'text'], ['destination', 'text'], ['time', 'text'], ['interval', 'text']]
-- Table: station
columns : [['id', 'number'], ['network name', 'text'], ['services', 'text'], ['local authority', 'text']]
-- Table: route
columns : [['train id', 'number'], ['station id', 'number']]
-- Table: weekly weather
columns : [['station id', 'number'], ['day of week', 'text'], ['high temperature', 'number'], ['low temperature', 'number'], ['precipitation', 'number'], ['wind speed mph', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `Find the name of the train whose route runs through greatest number of stations.` to a syntactically-correct PostgreSQL query.
| SELECT t1.name FROM train AS t1 JOIN route AS t2 ON t1.id = t2.train_id GROUP BY t2.train_id ORDER BY count(*) DESC LIMIT 1 |
Find the number of trains for each station, as well as the station network name and services. |
-- Language PostgreSQL
-- Tables:
-- Table: train
columns : [['id', 'number'], ['train number', 'number'], ['name', 'text'], ['origin', 'text'], ['destination', 'text'], ['time', 'text'], ['interval', 'text']]
-- Table: station
columns : [['id', 'number'], ['network name', 'text'], ['services', 'text'], ['local authority', 'text']]
-- Table: route
columns : [['train id', 'number'], ['station id', 'number']]
-- Table: weekly weather
columns : [['station id', 'number'], ['day of week', 'text'], ['high temperature', 'number'], ['low temperature', 'number'], ['precipitation', 'number'], ['wind speed mph', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `Find the number of trains for each station, as well as the station network name and services.` to a syntactically-correct PostgreSQL query.
| SELECT count(*) , t1.network_name , t1.services FROM station AS t1 JOIN route AS t2 ON t1.id = t2.station_id GROUP BY t2.station_id |
What is the average high temperature for each day of week? |
-- Language PostgreSQL
-- Tables:
-- Table: train
columns : [['id', 'number'], ['train number', 'number'], ['name', 'text'], ['origin', 'text'], ['destination', 'text'], ['time', 'text'], ['interval', 'text']]
-- Table: station
columns : [['id', 'number'], ['network name', 'text'], ['services', 'text'], ['local authority', 'text']]
-- Table: route
columns : [['train id', 'number'], ['station id', 'number']]
-- Table: weekly weather
columns : [['station id', 'number'], ['day of week', 'text'], ['high temperature', 'number'], ['low temperature', 'number'], ['precipitation', 'number'], ['wind speed mph', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `What is the average high temperature for each day of week?` to a syntactically-correct PostgreSQL query.
| SELECT avg(high_temperature) , day_of_week FROM weekly_weather GROUP BY day_of_week |
Give me the maximum low temperature and average precipitation at the Amersham station. |
-- Language PostgreSQL
-- Tables:
-- Table: train
columns : [['id', 'number'], ['train number', 'number'], ['name', 'text'], ['origin', 'text'], ['destination', 'text'], ['time', 'text'], ['interval', 'text']]
-- Table: station
columns : [['id', 'number'], ['network name', 'text'], ['services', 'text'], ['local authority', 'text']]
-- Table: route
columns : [['train id', 'number'], ['station id', 'number']]
-- Table: weekly weather
columns : [['station id', 'number'], ['day of week', 'text'], ['high temperature', 'number'], ['low temperature', 'number'], ['precipitation', 'number'], ['wind speed mph', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `Give me the maximum low temperature and average precipitation at the Amersham station.` to a syntactically-correct PostgreSQL query.
| SELECT max(t1.low_temperature) , avg(t1.precipitation) FROM weekly_weather AS t1 JOIN station AS t2 ON t1.station_id = t2.id WHERE t2.network_name = "Amersham" |
Find names and times of trains that run through stations for the local authority Chiltern. |
-- Language PostgreSQL
-- Tables:
-- Table: train
columns : [['id', 'number'], ['train number', 'number'], ['name', 'text'], ['origin', 'text'], ['destination', 'text'], ['time', 'text'], ['interval', 'text']]
-- Table: station
columns : [['id', 'number'], ['network name', 'text'], ['services', 'text'], ['local authority', 'text']]
-- Table: route
columns : [['train id', 'number'], ['station id', 'number']]
-- Table: weekly weather
columns : [['station id', 'number'], ['day of week', 'text'], ['high temperature', 'number'], ['low temperature', 'number'], ['precipitation', 'number'], ['wind speed mph', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `Find names and times of trains that run through stations for the local authority Chiltern.` to a syntactically-correct PostgreSQL query.
| SELECT t3.name , t3.time FROM station AS t1 JOIN route AS t2 ON t1.id = t2.station_id JOIN train AS t3 ON t2.train_id = t3.id WHERE t1.local_authority = "Chiltern" |
How many different services are provided by all stations? |
-- Language PostgreSQL
-- Tables:
-- Table: train
columns : [['id', 'number'], ['train number', 'number'], ['name', 'text'], ['origin', 'text'], ['destination', 'text'], ['time', 'text'], ['interval', 'text']]
-- Table: station
columns : [['id', 'number'], ['network name', 'text'], ['services', 'text'], ['local authority', 'text']]
-- Table: route
columns : [['train id', 'number'], ['station id', 'number']]
-- Table: weekly weather
columns : [['station id', 'number'], ['day of week', 'text'], ['high temperature', 'number'], ['low temperature', 'number'], ['precipitation', 'number'], ['wind speed mph', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `How many different services are provided by all stations?` to a syntactically-correct PostgreSQL query.
| SELECT count(DISTINCT services) FROM station |
Find the id and local authority of the station with has the highest average high temperature. |
-- Language PostgreSQL
-- Tables:
-- Table: train
columns : [['id', 'number'], ['train number', 'number'], ['name', 'text'], ['origin', 'text'], ['destination', 'text'], ['time', 'text'], ['interval', 'text']]
-- Table: station
columns : [['id', 'number'], ['network name', 'text'], ['services', 'text'], ['local authority', 'text']]
-- Table: route
columns : [['train id', 'number'], ['station id', 'number']]
-- Table: weekly weather
columns : [['station id', 'number'], ['day of week', 'text'], ['high temperature', 'number'], ['low temperature', 'number'], ['precipitation', 'number'], ['wind speed mph', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `Find the id and local authority of the station with has the highest average high temperature.` to a syntactically-correct PostgreSQL query.
| SELECT t2.id , t2.local_authority FROM weekly_weather AS t1 JOIN station AS t2 ON t1.station_id = t2.id GROUP BY t1.station_id ORDER BY avg(high_temperature) DESC LIMIT 1 |
Find the id and local authority of the station whose maximum precipitation is higher than 50. |
-- Language PostgreSQL
-- Tables:
-- Table: train
columns : [['id', 'number'], ['train number', 'number'], ['name', 'text'], ['origin', 'text'], ['destination', 'text'], ['time', 'text'], ['interval', 'text']]
-- Table: station
columns : [['id', 'number'], ['network name', 'text'], ['services', 'text'], ['local authority', 'text']]
-- Table: route
columns : [['train id', 'number'], ['station id', 'number']]
-- Table: weekly weather
columns : [['station id', 'number'], ['day of week', 'text'], ['high temperature', 'number'], ['low temperature', 'number'], ['precipitation', 'number'], ['wind speed mph', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `Find the id and local authority of the station whose maximum precipitation is higher than 50.` to a syntactically-correct PostgreSQL query.
| SELECT t2.id , t2.local_authority FROM weekly_weather AS t1 JOIN station AS t2 ON t1.station_id = t2.id GROUP BY t1.station_id HAVING max(t1.precipitation) > 50 |
show the lowest low temperature and highest wind speed in miles per hour. |
-- Language PostgreSQL
-- Tables:
-- Table: train
columns : [['id', 'number'], ['train number', 'number'], ['name', 'text'], ['origin', 'text'], ['destination', 'text'], ['time', 'text'], ['interval', 'text']]
-- Table: station
columns : [['id', 'number'], ['network name', 'text'], ['services', 'text'], ['local authority', 'text']]
-- Table: route
columns : [['train id', 'number'], ['station id', 'number']]
-- Table: weekly weather
columns : [['station id', 'number'], ['day of week', 'text'], ['high temperature', 'number'], ['low temperature', 'number'], ['precipitation', 'number'], ['wind speed mph', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `show the lowest low temperature and highest wind speed in miles per hour.` to a syntactically-correct PostgreSQL query.
| SELECT min(low_temperature) , max(wind_speed_mph) FROM weekly_weather |
Find the origins from which more than 1 train starts. |
-- Language PostgreSQL
-- Tables:
-- Table: train
columns : [['id', 'number'], ['train number', 'number'], ['name', 'text'], ['origin', 'text'], ['destination', 'text'], ['time', 'text'], ['interval', 'text']]
-- Table: station
columns : [['id', 'number'], ['network name', 'text'], ['services', 'text'], ['local authority', 'text']]
-- Table: route
columns : [['train id', 'number'], ['station id', 'number']]
-- Table: weekly weather
columns : [['station id', 'number'], ['day of week', 'text'], ['high temperature', 'number'], ['low temperature', 'number'], ['precipitation', 'number'], ['wind speed mph', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `Find the origins from which more than 1 train starts.` to a syntactically-correct PostgreSQL query.
| SELECT origin FROM train GROUP BY origin HAVING count(*) > 1 |
Find the number of professors in accounting department. |
-- Language PostgreSQL
-- Tables:
-- Table: class
columns : [['class code', 'text'], ['course code', 'text'], ['class section', 'text'], ['class time', 'text'], ['class room', 'text'], ['professor employee number', 'number']]
-- Table: course
columns : [['course code', 'text'], ['department code', 'text'], ['course description', 'text'], ['course credit', 'number']]
-- Table: department
columns : [['department code', 'text'], ['department name', 'text'], ['school code', 'text'], ['employee number', 'number'], ['department address', 'text'], ['department extension', 'text']]
-- Table: employee
columns : [['employee number', 'number'], ['employee last name', 'text'], ['employee first name', 'text'], ['employee initial', 'text'], ['employee job code', 'text'], ['employee hire date', 'time'], ['employee date of birth', 'time']]
-- Table: enroll
columns : [['class code', 'text'], ['student number', 'number'], ['enroll grade', 'text']]
-- Table: professor
columns : [['employee number', 'number'], ['department code', 'text'], ['professor office', 'text'], ['professor extension', 'text'], ['professor high degree', 'text']]
-- Table: student
columns : [['student num', 'number'], ['student last name', 'text'], ['student first name', 'text'], ['student init', 'text'], ['student date of birth', 'time'], ['student class hours took', 'number'], ['student class', 'text'], ['student gpa', 'number'], ['student transfer', 'number'], ['department code', 'text'], ['student phone', 'text'], ['professor number', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `Find the number of professors in accounting department.` to a syntactically-correct PostgreSQL query.
| SELECT count(*) FROM professor AS T1 JOIN department AS T2 ON T1.dept_code = T2.dept_code WHERE DEPT_NAME = "Accounting" |
How many professors are in the accounting dept? |
-- Language PostgreSQL
-- Tables:
-- Table: class
columns : [['class code', 'text'], ['course code', 'text'], ['class section', 'text'], ['class time', 'text'], ['class room', 'text'], ['professor employee number', 'number']]
-- Table: course
columns : [['course code', 'text'], ['department code', 'text'], ['course description', 'text'], ['course credit', 'number']]
-- Table: department
columns : [['department code', 'text'], ['department name', 'text'], ['school code', 'text'], ['employee number', 'number'], ['department address', 'text'], ['department extension', 'text']]
-- Table: employee
columns : [['employee number', 'number'], ['employee last name', 'text'], ['employee first name', 'text'], ['employee initial', 'text'], ['employee job code', 'text'], ['employee hire date', 'time'], ['employee date of birth', 'time']]
-- Table: enroll
columns : [['class code', 'text'], ['student number', 'number'], ['enroll grade', 'text']]
-- Table: professor
columns : [['employee number', 'number'], ['department code', 'text'], ['professor office', 'text'], ['professor extension', 'text'], ['professor high degree', 'text']]
-- Table: student
columns : [['student num', 'number'], ['student last name', 'text'], ['student first name', 'text'], ['student init', 'text'], ['student date of birth', 'time'], ['student class hours took', 'number'], ['student class', 'text'], ['student gpa', 'number'], ['student transfer', 'number'], ['department code', 'text'], ['student phone', 'text'], ['professor number', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `How many professors are in the accounting dept?` to a syntactically-correct PostgreSQL query.
| SELECT count(*) FROM professor AS T1 JOIN department AS T2 ON T1.dept_code = T2.dept_code WHERE DEPT_NAME = "Accounting" |
How many professors are teaching class with code ACCT-211? |
-- Language PostgreSQL
-- Tables:
-- Table: class
columns : [['class code', 'text'], ['course code', 'text'], ['class section', 'text'], ['class time', 'text'], ['class room', 'text'], ['professor employee number', 'number']]
-- Table: course
columns : [['course code', 'text'], ['department code', 'text'], ['course description', 'text'], ['course credit', 'number']]
-- Table: department
columns : [['department code', 'text'], ['department name', 'text'], ['school code', 'text'], ['employee number', 'number'], ['department address', 'text'], ['department extension', 'text']]
-- Table: employee
columns : [['employee number', 'number'], ['employee last name', 'text'], ['employee first name', 'text'], ['employee initial', 'text'], ['employee job code', 'text'], ['employee hire date', 'time'], ['employee date of birth', 'time']]
-- Table: enroll
columns : [['class code', 'text'], ['student number', 'number'], ['enroll grade', 'text']]
-- Table: professor
columns : [['employee number', 'number'], ['department code', 'text'], ['professor office', 'text'], ['professor extension', 'text'], ['professor high degree', 'text']]
-- Table: student
columns : [['student num', 'number'], ['student last name', 'text'], ['student first name', 'text'], ['student init', 'text'], ['student date of birth', 'time'], ['student class hours took', 'number'], ['student class', 'text'], ['student gpa', 'number'], ['student transfer', 'number'], ['department code', 'text'], ['student phone', 'text'], ['professor number', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `How many professors are teaching class with code ACCT-211?` to a syntactically-correct PostgreSQL query.
| SELECT count(DISTINCT PROF_NUM) FROM CLASS WHERE CRS_CODE = "ACCT-211" |
How many professors teach a class with the code ACCT-211? |
-- Language PostgreSQL
-- Tables:
-- Table: class
columns : [['class code', 'text'], ['course code', 'text'], ['class section', 'text'], ['class time', 'text'], ['class room', 'text'], ['professor employee number', 'number']]
-- Table: course
columns : [['course code', 'text'], ['department code', 'text'], ['course description', 'text'], ['course credit', 'number']]
-- Table: department
columns : [['department code', 'text'], ['department name', 'text'], ['school code', 'text'], ['employee number', 'number'], ['department address', 'text'], ['department extension', 'text']]
-- Table: employee
columns : [['employee number', 'number'], ['employee last name', 'text'], ['employee first name', 'text'], ['employee initial', 'text'], ['employee job code', 'text'], ['employee hire date', 'time'], ['employee date of birth', 'time']]
-- Table: enroll
columns : [['class code', 'text'], ['student number', 'number'], ['enroll grade', 'text']]
-- Table: professor
columns : [['employee number', 'number'], ['department code', 'text'], ['professor office', 'text'], ['professor extension', 'text'], ['professor high degree', 'text']]
-- Table: student
columns : [['student num', 'number'], ['student last name', 'text'], ['student first name', 'text'], ['student init', 'text'], ['student date of birth', 'time'], ['student class hours took', 'number'], ['student class', 'text'], ['student gpa', 'number'], ['student transfer', 'number'], ['department code', 'text'], ['student phone', 'text'], ['professor number', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `How many professors teach a class with the code ACCT-211?` to a syntactically-correct PostgreSQL query.
| SELECT count(DISTINCT PROF_NUM) FROM CLASS WHERE CRS_CODE = "ACCT-211" |
What is the first and last name of the professor in biology department? |
-- Language PostgreSQL
-- Tables:
-- Table: class
columns : [['class code', 'text'], ['course code', 'text'], ['class section', 'text'], ['class time', 'text'], ['class room', 'text'], ['professor employee number', 'number']]
-- Table: course
columns : [['course code', 'text'], ['department code', 'text'], ['course description', 'text'], ['course credit', 'number']]
-- Table: department
columns : [['department code', 'text'], ['department name', 'text'], ['school code', 'text'], ['employee number', 'number'], ['department address', 'text'], ['department extension', 'text']]
-- Table: employee
columns : [['employee number', 'number'], ['employee last name', 'text'], ['employee first name', 'text'], ['employee initial', 'text'], ['employee job code', 'text'], ['employee hire date', 'time'], ['employee date of birth', 'time']]
-- Table: enroll
columns : [['class code', 'text'], ['student number', 'number'], ['enroll grade', 'text']]
-- Table: professor
columns : [['employee number', 'number'], ['department code', 'text'], ['professor office', 'text'], ['professor extension', 'text'], ['professor high degree', 'text']]
-- Table: student
columns : [['student num', 'number'], ['student last name', 'text'], ['student first name', 'text'], ['student init', 'text'], ['student date of birth', 'time'], ['student class hours took', 'number'], ['student class', 'text'], ['student gpa', 'number'], ['student transfer', 'number'], ['department code', 'text'], ['student phone', 'text'], ['professor number', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `What is the first and last name of the professor in biology department?` to a syntactically-correct PostgreSQL query.
| SELECT T3.EMP_FNAME , T3.EMP_LNAME FROM professor AS T1 JOIN department AS T2 ON T1.dept_code = T2.dept_code JOIN employee AS T3 ON T1.EMP_NUM = T3.EMP_NUM WHERE DEPT_NAME = "Biology" |
What are the first and last name of all biology professors? |
-- Language PostgreSQL
-- Tables:
-- Table: class
columns : [['class code', 'text'], ['course code', 'text'], ['class section', 'text'], ['class time', 'text'], ['class room', 'text'], ['professor employee number', 'number']]
-- Table: course
columns : [['course code', 'text'], ['department code', 'text'], ['course description', 'text'], ['course credit', 'number']]
-- Table: department
columns : [['department code', 'text'], ['department name', 'text'], ['school code', 'text'], ['employee number', 'number'], ['department address', 'text'], ['department extension', 'text']]
-- Table: employee
columns : [['employee number', 'number'], ['employee last name', 'text'], ['employee first name', 'text'], ['employee initial', 'text'], ['employee job code', 'text'], ['employee hire date', 'time'], ['employee date of birth', 'time']]
-- Table: enroll
columns : [['class code', 'text'], ['student number', 'number'], ['enroll grade', 'text']]
-- Table: professor
columns : [['employee number', 'number'], ['department code', 'text'], ['professor office', 'text'], ['professor extension', 'text'], ['professor high degree', 'text']]
-- Table: student
columns : [['student num', 'number'], ['student last name', 'text'], ['student first name', 'text'], ['student init', 'text'], ['student date of birth', 'time'], ['student class hours took', 'number'], ['student class', 'text'], ['student gpa', 'number'], ['student transfer', 'number'], ['department code', 'text'], ['student phone', 'text'], ['professor number', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `What are the first and last name of all biology professors?` to a syntactically-correct PostgreSQL query.
| SELECT T3.EMP_FNAME , T3.EMP_LNAME FROM professor AS T1 JOIN department AS T2 ON T1.dept_code = T2.dept_code JOIN employee AS T3 ON T1.EMP_NUM = T3.EMP_NUM WHERE DEPT_NAME = "Biology" |
What are the first names and date of birth of professors teaching course ACCT-211? |
-- Language PostgreSQL
-- Tables:
-- Table: class
columns : [['class code', 'text'], ['course code', 'text'], ['class section', 'text'], ['class time', 'text'], ['class room', 'text'], ['professor employee number', 'number']]
-- Table: course
columns : [['course code', 'text'], ['department code', 'text'], ['course description', 'text'], ['course credit', 'number']]
-- Table: department
columns : [['department code', 'text'], ['department name', 'text'], ['school code', 'text'], ['employee number', 'number'], ['department address', 'text'], ['department extension', 'text']]
-- Table: employee
columns : [['employee number', 'number'], ['employee last name', 'text'], ['employee first name', 'text'], ['employee initial', 'text'], ['employee job code', 'text'], ['employee hire date', 'time'], ['employee date of birth', 'time']]
-- Table: enroll
columns : [['class code', 'text'], ['student number', 'number'], ['enroll grade', 'text']]
-- Table: professor
columns : [['employee number', 'number'], ['department code', 'text'], ['professor office', 'text'], ['professor extension', 'text'], ['professor high degree', 'text']]
-- Table: student
columns : [['student num', 'number'], ['student last name', 'text'], ['student first name', 'text'], ['student init', 'text'], ['student date of birth', 'time'], ['student class hours took', 'number'], ['student class', 'text'], ['student gpa', 'number'], ['student transfer', 'number'], ['department code', 'text'], ['student phone', 'text'], ['professor number', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `What are the first names and date of birth of professors teaching course ACCT-211?` to a syntactically-correct PostgreSQL query.
| SELECT DISTINCT T1.EMP_FNAME , T1.EMP_DOB FROM employee AS T1 JOIN CLASS AS T2 ON T1.EMP_NUM = T2.PROF_NUM WHERE CRS_CODE = "ACCT-211" |
What are the first names and birthdates of the professors in charge of ACCT-211? |
-- Language PostgreSQL
-- Tables:
-- Table: class
columns : [['class code', 'text'], ['course code', 'text'], ['class section', 'text'], ['class time', 'text'], ['class room', 'text'], ['professor employee number', 'number']]
-- Table: course
columns : [['course code', 'text'], ['department code', 'text'], ['course description', 'text'], ['course credit', 'number']]
-- Table: department
columns : [['department code', 'text'], ['department name', 'text'], ['school code', 'text'], ['employee number', 'number'], ['department address', 'text'], ['department extension', 'text']]
-- Table: employee
columns : [['employee number', 'number'], ['employee last name', 'text'], ['employee first name', 'text'], ['employee initial', 'text'], ['employee job code', 'text'], ['employee hire date', 'time'], ['employee date of birth', 'time']]
-- Table: enroll
columns : [['class code', 'text'], ['student number', 'number'], ['enroll grade', 'text']]
-- Table: professor
columns : [['employee number', 'number'], ['department code', 'text'], ['professor office', 'text'], ['professor extension', 'text'], ['professor high degree', 'text']]
-- Table: student
columns : [['student num', 'number'], ['student last name', 'text'], ['student first name', 'text'], ['student init', 'text'], ['student date of birth', 'time'], ['student class hours took', 'number'], ['student class', 'text'], ['student gpa', 'number'], ['student transfer', 'number'], ['department code', 'text'], ['student phone', 'text'], ['professor number', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `What are the first names and birthdates of the professors in charge of ACCT-211?` to a syntactically-correct PostgreSQL query.
| SELECT DISTINCT T1.EMP_FNAME , T1.EMP_DOB FROM employee AS T1 JOIN CLASS AS T2 ON T1.EMP_NUM = T2.PROF_NUM WHERE CRS_CODE = "ACCT-211" |
How many classes are professor whose last name is Graztevski has? |
-- Language PostgreSQL
-- Tables:
-- Table: class
columns : [['class code', 'text'], ['course code', 'text'], ['class section', 'text'], ['class time', 'text'], ['class room', 'text'], ['professor employee number', 'number']]
-- Table: course
columns : [['course code', 'text'], ['department code', 'text'], ['course description', 'text'], ['course credit', 'number']]
-- Table: department
columns : [['department code', 'text'], ['department name', 'text'], ['school code', 'text'], ['employee number', 'number'], ['department address', 'text'], ['department extension', 'text']]
-- Table: employee
columns : [['employee number', 'number'], ['employee last name', 'text'], ['employee first name', 'text'], ['employee initial', 'text'], ['employee job code', 'text'], ['employee hire date', 'time'], ['employee date of birth', 'time']]
-- Table: enroll
columns : [['class code', 'text'], ['student number', 'number'], ['enroll grade', 'text']]
-- Table: professor
columns : [['employee number', 'number'], ['department code', 'text'], ['professor office', 'text'], ['professor extension', 'text'], ['professor high degree', 'text']]
-- Table: student
columns : [['student num', 'number'], ['student last name', 'text'], ['student first name', 'text'], ['student init', 'text'], ['student date of birth', 'time'], ['student class hours took', 'number'], ['student class', 'text'], ['student gpa', 'number'], ['student transfer', 'number'], ['department code', 'text'], ['student phone', 'text'], ['professor number', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `How many classes are professor whose last name is Graztevski has?` to a syntactically-correct PostgreSQL query.
| SELECT count(*) FROM employee AS T1 JOIN CLASS AS T2 ON T1.EMP_NUM = T2.PROF_NUM WHERE T1.EMP_LNAME = 'Graztevski' |
How many classes does the professor whose last name is Graztevski teach? |
-- Language PostgreSQL
-- Tables:
-- Table: class
columns : [['class code', 'text'], ['course code', 'text'], ['class section', 'text'], ['class time', 'text'], ['class room', 'text'], ['professor employee number', 'number']]
-- Table: course
columns : [['course code', 'text'], ['department code', 'text'], ['course description', 'text'], ['course credit', 'number']]
-- Table: department
columns : [['department code', 'text'], ['department name', 'text'], ['school code', 'text'], ['employee number', 'number'], ['department address', 'text'], ['department extension', 'text']]
-- Table: employee
columns : [['employee number', 'number'], ['employee last name', 'text'], ['employee first name', 'text'], ['employee initial', 'text'], ['employee job code', 'text'], ['employee hire date', 'time'], ['employee date of birth', 'time']]
-- Table: enroll
columns : [['class code', 'text'], ['student number', 'number'], ['enroll grade', 'text']]
-- Table: professor
columns : [['employee number', 'number'], ['department code', 'text'], ['professor office', 'text'], ['professor extension', 'text'], ['professor high degree', 'text']]
-- Table: student
columns : [['student num', 'number'], ['student last name', 'text'], ['student first name', 'text'], ['student init', 'text'], ['student date of birth', 'time'], ['student class hours took', 'number'], ['student class', 'text'], ['student gpa', 'number'], ['student transfer', 'number'], ['department code', 'text'], ['student phone', 'text'], ['professor number', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `How many classes does the professor whose last name is Graztevski teach?` to a syntactically-correct PostgreSQL query.
| SELECT count(*) FROM employee AS T1 JOIN CLASS AS T2 ON T1.EMP_NUM = T2.PROF_NUM WHERE T1.EMP_LNAME = 'Graztevski' |
What is the code of the school where the accounting department belongs to? |
-- Language PostgreSQL
-- Tables:
-- Table: class
columns : [['class code', 'text'], ['course code', 'text'], ['class section', 'text'], ['class time', 'text'], ['class room', 'text'], ['professor employee number', 'number']]
-- Table: course
columns : [['course code', 'text'], ['department code', 'text'], ['course description', 'text'], ['course credit', 'number']]
-- Table: department
columns : [['department code', 'text'], ['department name', 'text'], ['school code', 'text'], ['employee number', 'number'], ['department address', 'text'], ['department extension', 'text']]
-- Table: employee
columns : [['employee number', 'number'], ['employee last name', 'text'], ['employee first name', 'text'], ['employee initial', 'text'], ['employee job code', 'text'], ['employee hire date', 'time'], ['employee date of birth', 'time']]
-- Table: enroll
columns : [['class code', 'text'], ['student number', 'number'], ['enroll grade', 'text']]
-- Table: professor
columns : [['employee number', 'number'], ['department code', 'text'], ['professor office', 'text'], ['professor extension', 'text'], ['professor high degree', 'text']]
-- Table: student
columns : [['student num', 'number'], ['student last name', 'text'], ['student first name', 'text'], ['student init', 'text'], ['student date of birth', 'time'], ['student class hours took', 'number'], ['student class', 'text'], ['student gpa', 'number'], ['student transfer', 'number'], ['department code', 'text'], ['student phone', 'text'], ['professor number', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `What is the code of the school where the accounting department belongs to?` to a syntactically-correct PostgreSQL query.
| SELECT school_code FROM department WHERE dept_name = "Accounting" |
What is the school code of the accounting department? |
-- Language PostgreSQL
-- Tables:
-- Table: class
columns : [['class code', 'text'], ['course code', 'text'], ['class section', 'text'], ['class time', 'text'], ['class room', 'text'], ['professor employee number', 'number']]
-- Table: course
columns : [['course code', 'text'], ['department code', 'text'], ['course description', 'text'], ['course credit', 'number']]
-- Table: department
columns : [['department code', 'text'], ['department name', 'text'], ['school code', 'text'], ['employee number', 'number'], ['department address', 'text'], ['department extension', 'text']]
-- Table: employee
columns : [['employee number', 'number'], ['employee last name', 'text'], ['employee first name', 'text'], ['employee initial', 'text'], ['employee job code', 'text'], ['employee hire date', 'time'], ['employee date of birth', 'time']]
-- Table: enroll
columns : [['class code', 'text'], ['student number', 'number'], ['enroll grade', 'text']]
-- Table: professor
columns : [['employee number', 'number'], ['department code', 'text'], ['professor office', 'text'], ['professor extension', 'text'], ['professor high degree', 'text']]
-- Table: student
columns : [['student num', 'number'], ['student last name', 'text'], ['student first name', 'text'], ['student init', 'text'], ['student date of birth', 'time'], ['student class hours took', 'number'], ['student class', 'text'], ['student gpa', 'number'], ['student transfer', 'number'], ['department code', 'text'], ['student phone', 'text'], ['professor number', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `What is the school code of the accounting department?` to a syntactically-correct PostgreSQL query.
| SELECT school_code FROM department WHERE dept_name = "Accounting" |
How many credits does course CIS-220 have, and what its description? |
-- Language PostgreSQL
-- Tables:
-- Table: class
columns : [['class code', 'text'], ['course code', 'text'], ['class section', 'text'], ['class time', 'text'], ['class room', 'text'], ['professor employee number', 'number']]
-- Table: course
columns : [['course code', 'text'], ['department code', 'text'], ['course description', 'text'], ['course credit', 'number']]
-- Table: department
columns : [['department code', 'text'], ['department name', 'text'], ['school code', 'text'], ['employee number', 'number'], ['department address', 'text'], ['department extension', 'text']]
-- Table: employee
columns : [['employee number', 'number'], ['employee last name', 'text'], ['employee first name', 'text'], ['employee initial', 'text'], ['employee job code', 'text'], ['employee hire date', 'time'], ['employee date of birth', 'time']]
-- Table: enroll
columns : [['class code', 'text'], ['student number', 'number'], ['enroll grade', 'text']]
-- Table: professor
columns : [['employee number', 'number'], ['department code', 'text'], ['professor office', 'text'], ['professor extension', 'text'], ['professor high degree', 'text']]
-- Table: student
columns : [['student num', 'number'], ['student last name', 'text'], ['student first name', 'text'], ['student init', 'text'], ['student date of birth', 'time'], ['student class hours took', 'number'], ['student class', 'text'], ['student gpa', 'number'], ['student transfer', 'number'], ['department code', 'text'], ['student phone', 'text'], ['professor number', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `How many credits does course CIS-220 have, and what its description?` to a syntactically-correct PostgreSQL query.
| SELECT crs_credit , crs_description FROM course WHERE crs_code = 'CIS-220' |
What is the description for the CIS-220 and how many credits does it have? |
-- Language PostgreSQL
-- Tables:
-- Table: class
columns : [['class code', 'text'], ['course code', 'text'], ['class section', 'text'], ['class time', 'text'], ['class room', 'text'], ['professor employee number', 'number']]
-- Table: course
columns : [['course code', 'text'], ['department code', 'text'], ['course description', 'text'], ['course credit', 'number']]
-- Table: department
columns : [['department code', 'text'], ['department name', 'text'], ['school code', 'text'], ['employee number', 'number'], ['department address', 'text'], ['department extension', 'text']]
-- Table: employee
columns : [['employee number', 'number'], ['employee last name', 'text'], ['employee first name', 'text'], ['employee initial', 'text'], ['employee job code', 'text'], ['employee hire date', 'time'], ['employee date of birth', 'time']]
-- Table: enroll
columns : [['class code', 'text'], ['student number', 'number'], ['enroll grade', 'text']]
-- Table: professor
columns : [['employee number', 'number'], ['department code', 'text'], ['professor office', 'text'], ['professor extension', 'text'], ['professor high degree', 'text']]
-- Table: student
columns : [['student num', 'number'], ['student last name', 'text'], ['student first name', 'text'], ['student init', 'text'], ['student date of birth', 'time'], ['student class hours took', 'number'], ['student class', 'text'], ['student gpa', 'number'], ['student transfer', 'number'], ['department code', 'text'], ['student phone', 'text'], ['professor number', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `What is the description for the CIS-220 and how many credits does it have?` to a syntactically-correct PostgreSQL query.
| SELECT crs_credit , crs_description FROM course WHERE crs_code = 'CIS-220' |
what is the address of history department? |
-- Language PostgreSQL
-- Tables:
-- Table: class
columns : [['class code', 'text'], ['course code', 'text'], ['class section', 'text'], ['class time', 'text'], ['class room', 'text'], ['professor employee number', 'number']]
-- Table: course
columns : [['course code', 'text'], ['department code', 'text'], ['course description', 'text'], ['course credit', 'number']]
-- Table: department
columns : [['department code', 'text'], ['department name', 'text'], ['school code', 'text'], ['employee number', 'number'], ['department address', 'text'], ['department extension', 'text']]
-- Table: employee
columns : [['employee number', 'number'], ['employee last name', 'text'], ['employee first name', 'text'], ['employee initial', 'text'], ['employee job code', 'text'], ['employee hire date', 'time'], ['employee date of birth', 'time']]
-- Table: enroll
columns : [['class code', 'text'], ['student number', 'number'], ['enroll grade', 'text']]
-- Table: professor
columns : [['employee number', 'number'], ['department code', 'text'], ['professor office', 'text'], ['professor extension', 'text'], ['professor high degree', 'text']]
-- Table: student
columns : [['student num', 'number'], ['student last name', 'text'], ['student first name', 'text'], ['student init', 'text'], ['student date of birth', 'time'], ['student class hours took', 'number'], ['student class', 'text'], ['student gpa', 'number'], ['student transfer', 'number'], ['department code', 'text'], ['student phone', 'text'], ['professor number', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `what is the address of history department?` to a syntactically-correct PostgreSQL query.
| SELECT dept_address FROM department WHERE dept_name = 'History' |
Where is the history department? |
-- Language PostgreSQL
-- Tables:
-- Table: class
columns : [['class code', 'text'], ['course code', 'text'], ['class section', 'text'], ['class time', 'text'], ['class room', 'text'], ['professor employee number', 'number']]
-- Table: course
columns : [['course code', 'text'], ['department code', 'text'], ['course description', 'text'], ['course credit', 'number']]
-- Table: department
columns : [['department code', 'text'], ['department name', 'text'], ['school code', 'text'], ['employee number', 'number'], ['department address', 'text'], ['department extension', 'text']]
-- Table: employee
columns : [['employee number', 'number'], ['employee last name', 'text'], ['employee first name', 'text'], ['employee initial', 'text'], ['employee job code', 'text'], ['employee hire date', 'time'], ['employee date of birth', 'time']]
-- Table: enroll
columns : [['class code', 'text'], ['student number', 'number'], ['enroll grade', 'text']]
-- Table: professor
columns : [['employee number', 'number'], ['department code', 'text'], ['professor office', 'text'], ['professor extension', 'text'], ['professor high degree', 'text']]
-- Table: student
columns : [['student num', 'number'], ['student last name', 'text'], ['student first name', 'text'], ['student init', 'text'], ['student date of birth', 'time'], ['student class hours took', 'number'], ['student class', 'text'], ['student gpa', 'number'], ['student transfer', 'number'], ['department code', 'text'], ['student phone', 'text'], ['professor number', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `Where is the history department?` to a syntactically-correct PostgreSQL query.
| SELECT dept_address FROM department WHERE dept_name = 'History' |
How many different locations does the school with code BUS has? |
-- Language PostgreSQL
-- Tables:
-- Table: class
columns : [['class code', 'text'], ['course code', 'text'], ['class section', 'text'], ['class time', 'text'], ['class room', 'text'], ['professor employee number', 'number']]
-- Table: course
columns : [['course code', 'text'], ['department code', 'text'], ['course description', 'text'], ['course credit', 'number']]
-- Table: department
columns : [['department code', 'text'], ['department name', 'text'], ['school code', 'text'], ['employee number', 'number'], ['department address', 'text'], ['department extension', 'text']]
-- Table: employee
columns : [['employee number', 'number'], ['employee last name', 'text'], ['employee first name', 'text'], ['employee initial', 'text'], ['employee job code', 'text'], ['employee hire date', 'time'], ['employee date of birth', 'time']]
-- Table: enroll
columns : [['class code', 'text'], ['student number', 'number'], ['enroll grade', 'text']]
-- Table: professor
columns : [['employee number', 'number'], ['department code', 'text'], ['professor office', 'text'], ['professor extension', 'text'], ['professor high degree', 'text']]
-- Table: student
columns : [['student num', 'number'], ['student last name', 'text'], ['student first name', 'text'], ['student init', 'text'], ['student date of birth', 'time'], ['student class hours took', 'number'], ['student class', 'text'], ['student gpa', 'number'], ['student transfer', 'number'], ['department code', 'text'], ['student phone', 'text'], ['professor number', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `How many different locations does the school with code BUS has?` to a syntactically-correct PostgreSQL query.
| SELECT count(DISTINCT dept_address) FROM department WHERE school_code = 'BUS' |
What are the different locations of the school with the code BUS? |
-- Language PostgreSQL
-- Tables:
-- Table: class
columns : [['class code', 'text'], ['course code', 'text'], ['class section', 'text'], ['class time', 'text'], ['class room', 'text'], ['professor employee number', 'number']]
-- Table: course
columns : [['course code', 'text'], ['department code', 'text'], ['course description', 'text'], ['course credit', 'number']]
-- Table: department
columns : [['department code', 'text'], ['department name', 'text'], ['school code', 'text'], ['employee number', 'number'], ['department address', 'text'], ['department extension', 'text']]
-- Table: employee
columns : [['employee number', 'number'], ['employee last name', 'text'], ['employee first name', 'text'], ['employee initial', 'text'], ['employee job code', 'text'], ['employee hire date', 'time'], ['employee date of birth', 'time']]
-- Table: enroll
columns : [['class code', 'text'], ['student number', 'number'], ['enroll grade', 'text']]
-- Table: professor
columns : [['employee number', 'number'], ['department code', 'text'], ['professor office', 'text'], ['professor extension', 'text'], ['professor high degree', 'text']]
-- Table: student
columns : [['student num', 'number'], ['student last name', 'text'], ['student first name', 'text'], ['student init', 'text'], ['student date of birth', 'time'], ['student class hours took', 'number'], ['student class', 'text'], ['student gpa', 'number'], ['student transfer', 'number'], ['department code', 'text'], ['student phone', 'text'], ['professor number', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `What are the different locations of the school with the code BUS?` to a syntactically-correct PostgreSQL query.
| SELECT count(DISTINCT dept_address) FROM department WHERE school_code = 'BUS' |
How many different locations does each school have? |
-- Language PostgreSQL
-- Tables:
-- Table: class
columns : [['class code', 'text'], ['course code', 'text'], ['class section', 'text'], ['class time', 'text'], ['class room', 'text'], ['professor employee number', 'number']]
-- Table: course
columns : [['course code', 'text'], ['department code', 'text'], ['course description', 'text'], ['course credit', 'number']]
-- Table: department
columns : [['department code', 'text'], ['department name', 'text'], ['school code', 'text'], ['employee number', 'number'], ['department address', 'text'], ['department extension', 'text']]
-- Table: employee
columns : [['employee number', 'number'], ['employee last name', 'text'], ['employee first name', 'text'], ['employee initial', 'text'], ['employee job code', 'text'], ['employee hire date', 'time'], ['employee date of birth', 'time']]
-- Table: enroll
columns : [['class code', 'text'], ['student number', 'number'], ['enroll grade', 'text']]
-- Table: professor
columns : [['employee number', 'number'], ['department code', 'text'], ['professor office', 'text'], ['professor extension', 'text'], ['professor high degree', 'text']]
-- Table: student
columns : [['student num', 'number'], ['student last name', 'text'], ['student first name', 'text'], ['student init', 'text'], ['student date of birth', 'time'], ['student class hours took', 'number'], ['student class', 'text'], ['student gpa', 'number'], ['student transfer', 'number'], ['department code', 'text'], ['student phone', 'text'], ['professor number', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `How many different locations does each school have?` to a syntactically-correct PostgreSQL query.
| SELECT count(DISTINCT dept_address) , school_code FROM department GROUP BY school_code |
Count different addresses of each school. |
-- Language PostgreSQL
-- Tables:
-- Table: class
columns : [['class code', 'text'], ['course code', 'text'], ['class section', 'text'], ['class time', 'text'], ['class room', 'text'], ['professor employee number', 'number']]
-- Table: course
columns : [['course code', 'text'], ['department code', 'text'], ['course description', 'text'], ['course credit', 'number']]
-- Table: department
columns : [['department code', 'text'], ['department name', 'text'], ['school code', 'text'], ['employee number', 'number'], ['department address', 'text'], ['department extension', 'text']]
-- Table: employee
columns : [['employee number', 'number'], ['employee last name', 'text'], ['employee first name', 'text'], ['employee initial', 'text'], ['employee job code', 'text'], ['employee hire date', 'time'], ['employee date of birth', 'time']]
-- Table: enroll
columns : [['class code', 'text'], ['student number', 'number'], ['enroll grade', 'text']]
-- Table: professor
columns : [['employee number', 'number'], ['department code', 'text'], ['professor office', 'text'], ['professor extension', 'text'], ['professor high degree', 'text']]
-- Table: student
columns : [['student num', 'number'], ['student last name', 'text'], ['student first name', 'text'], ['student init', 'text'], ['student date of birth', 'time'], ['student class hours took', 'number'], ['student class', 'text'], ['student gpa', 'number'], ['student transfer', 'number'], ['department code', 'text'], ['student phone', 'text'], ['professor number', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `Count different addresses of each school.` to a syntactically-correct PostgreSQL query.
| SELECT count(DISTINCT dept_address) , school_code FROM department GROUP BY school_code |
Find the description and credit for the course QM-261? |
-- Language PostgreSQL
-- Tables:
-- Table: class
columns : [['class code', 'text'], ['course code', 'text'], ['class section', 'text'], ['class time', 'text'], ['class room', 'text'], ['professor employee number', 'number']]
-- Table: course
columns : [['course code', 'text'], ['department code', 'text'], ['course description', 'text'], ['course credit', 'number']]
-- Table: department
columns : [['department code', 'text'], ['department name', 'text'], ['school code', 'text'], ['employee number', 'number'], ['department address', 'text'], ['department extension', 'text']]
-- Table: employee
columns : [['employee number', 'number'], ['employee last name', 'text'], ['employee first name', 'text'], ['employee initial', 'text'], ['employee job code', 'text'], ['employee hire date', 'time'], ['employee date of birth', 'time']]
-- Table: enroll
columns : [['class code', 'text'], ['student number', 'number'], ['enroll grade', 'text']]
-- Table: professor
columns : [['employee number', 'number'], ['department code', 'text'], ['professor office', 'text'], ['professor extension', 'text'], ['professor high degree', 'text']]
-- Table: student
columns : [['student num', 'number'], ['student last name', 'text'], ['student first name', 'text'], ['student init', 'text'], ['student date of birth', 'time'], ['student class hours took', 'number'], ['student class', 'text'], ['student gpa', 'number'], ['student transfer', 'number'], ['department code', 'text'], ['student phone', 'text'], ['professor number', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `Find the description and credit for the course QM-261?` to a syntactically-correct PostgreSQL query.
| SELECT crs_credit , crs_description FROM course WHERE crs_code = 'QM-261' |
What is the course description and number of credits for QM-261? |
-- Language PostgreSQL
-- Tables:
-- Table: class
columns : [['class code', 'text'], ['course code', 'text'], ['class section', 'text'], ['class time', 'text'], ['class room', 'text'], ['professor employee number', 'number']]
-- Table: course
columns : [['course code', 'text'], ['department code', 'text'], ['course description', 'text'], ['course credit', 'number']]
-- Table: department
columns : [['department code', 'text'], ['department name', 'text'], ['school code', 'text'], ['employee number', 'number'], ['department address', 'text'], ['department extension', 'text']]
-- Table: employee
columns : [['employee number', 'number'], ['employee last name', 'text'], ['employee first name', 'text'], ['employee initial', 'text'], ['employee job code', 'text'], ['employee hire date', 'time'], ['employee date of birth', 'time']]
-- Table: enroll
columns : [['class code', 'text'], ['student number', 'number'], ['enroll grade', 'text']]
-- Table: professor
columns : [['employee number', 'number'], ['department code', 'text'], ['professor office', 'text'], ['professor extension', 'text'], ['professor high degree', 'text']]
-- Table: student
columns : [['student num', 'number'], ['student last name', 'text'], ['student first name', 'text'], ['student init', 'text'], ['student date of birth', 'time'], ['student class hours took', 'number'], ['student class', 'text'], ['student gpa', 'number'], ['student transfer', 'number'], ['department code', 'text'], ['student phone', 'text'], ['professor number', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `What is the course description and number of credits for QM-261?` to a syntactically-correct PostgreSQL query.
| SELECT crs_credit , crs_description FROM course WHERE crs_code = 'QM-261' |
Find the number of departments in each school. |
-- Language PostgreSQL
-- Tables:
-- Table: class
columns : [['class code', 'text'], ['course code', 'text'], ['class section', 'text'], ['class time', 'text'], ['class room', 'text'], ['professor employee number', 'number']]
-- Table: course
columns : [['course code', 'text'], ['department code', 'text'], ['course description', 'text'], ['course credit', 'number']]
-- Table: department
columns : [['department code', 'text'], ['department name', 'text'], ['school code', 'text'], ['employee number', 'number'], ['department address', 'text'], ['department extension', 'text']]
-- Table: employee
columns : [['employee number', 'number'], ['employee last name', 'text'], ['employee first name', 'text'], ['employee initial', 'text'], ['employee job code', 'text'], ['employee hire date', 'time'], ['employee date of birth', 'time']]
-- Table: enroll
columns : [['class code', 'text'], ['student number', 'number'], ['enroll grade', 'text']]
-- Table: professor
columns : [['employee number', 'number'], ['department code', 'text'], ['professor office', 'text'], ['professor extension', 'text'], ['professor high degree', 'text']]
-- Table: student
columns : [['student num', 'number'], ['student last name', 'text'], ['student first name', 'text'], ['student init', 'text'], ['student date of birth', 'time'], ['student class hours took', 'number'], ['student class', 'text'], ['student gpa', 'number'], ['student transfer', 'number'], ['department code', 'text'], ['student phone', 'text'], ['professor number', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `Find the number of departments in each school.` to a syntactically-correct PostgreSQL query.
| SELECT count(DISTINCT dept_name) , school_code FROM department GROUP BY school_code |
How many departments are in each school? |
-- Language PostgreSQL
-- Tables:
-- Table: class
columns : [['class code', 'text'], ['course code', 'text'], ['class section', 'text'], ['class time', 'text'], ['class room', 'text'], ['professor employee number', 'number']]
-- Table: course
columns : [['course code', 'text'], ['department code', 'text'], ['course description', 'text'], ['course credit', 'number']]
-- Table: department
columns : [['department code', 'text'], ['department name', 'text'], ['school code', 'text'], ['employee number', 'number'], ['department address', 'text'], ['department extension', 'text']]
-- Table: employee
columns : [['employee number', 'number'], ['employee last name', 'text'], ['employee first name', 'text'], ['employee initial', 'text'], ['employee job code', 'text'], ['employee hire date', 'time'], ['employee date of birth', 'time']]
-- Table: enroll
columns : [['class code', 'text'], ['student number', 'number'], ['enroll grade', 'text']]
-- Table: professor
columns : [['employee number', 'number'], ['department code', 'text'], ['professor office', 'text'], ['professor extension', 'text'], ['professor high degree', 'text']]
-- Table: student
columns : [['student num', 'number'], ['student last name', 'text'], ['student first name', 'text'], ['student init', 'text'], ['student date of birth', 'time'], ['student class hours took', 'number'], ['student class', 'text'], ['student gpa', 'number'], ['student transfer', 'number'], ['department code', 'text'], ['student phone', 'text'], ['professor number', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `How many departments are in each school?` to a syntactically-correct PostgreSQL query.
| SELECT count(DISTINCT dept_name) , school_code FROM department GROUP BY school_code |
Find the number of different departments in each school whose number of different departments is less than 5. |
-- Language PostgreSQL
-- Tables:
-- Table: class
columns : [['class code', 'text'], ['course code', 'text'], ['class section', 'text'], ['class time', 'text'], ['class room', 'text'], ['professor employee number', 'number']]
-- Table: course
columns : [['course code', 'text'], ['department code', 'text'], ['course description', 'text'], ['course credit', 'number']]
-- Table: department
columns : [['department code', 'text'], ['department name', 'text'], ['school code', 'text'], ['employee number', 'number'], ['department address', 'text'], ['department extension', 'text']]
-- Table: employee
columns : [['employee number', 'number'], ['employee last name', 'text'], ['employee first name', 'text'], ['employee initial', 'text'], ['employee job code', 'text'], ['employee hire date', 'time'], ['employee date of birth', 'time']]
-- Table: enroll
columns : [['class code', 'text'], ['student number', 'number'], ['enroll grade', 'text']]
-- Table: professor
columns : [['employee number', 'number'], ['department code', 'text'], ['professor office', 'text'], ['professor extension', 'text'], ['professor high degree', 'text']]
-- Table: student
columns : [['student num', 'number'], ['student last name', 'text'], ['student first name', 'text'], ['student init', 'text'], ['student date of birth', 'time'], ['student class hours took', 'number'], ['student class', 'text'], ['student gpa', 'number'], ['student transfer', 'number'], ['department code', 'text'], ['student phone', 'text'], ['professor number', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `Find the number of different departments in each school whose number of different departments is less than 5.` to a syntactically-correct PostgreSQL query.
| SELECT count(DISTINCT dept_name) , school_code FROM department GROUP BY school_code HAVING count(DISTINCT dept_name) < 5 |
How many different departments are there in each school that has less than 5 apartments? |
-- Language PostgreSQL
-- Tables:
-- Table: class
columns : [['class code', 'text'], ['course code', 'text'], ['class section', 'text'], ['class time', 'text'], ['class room', 'text'], ['professor employee number', 'number']]
-- Table: course
columns : [['course code', 'text'], ['department code', 'text'], ['course description', 'text'], ['course credit', 'number']]
-- Table: department
columns : [['department code', 'text'], ['department name', 'text'], ['school code', 'text'], ['employee number', 'number'], ['department address', 'text'], ['department extension', 'text']]
-- Table: employee
columns : [['employee number', 'number'], ['employee last name', 'text'], ['employee first name', 'text'], ['employee initial', 'text'], ['employee job code', 'text'], ['employee hire date', 'time'], ['employee date of birth', 'time']]
-- Table: enroll
columns : [['class code', 'text'], ['student number', 'number'], ['enroll grade', 'text']]
-- Table: professor
columns : [['employee number', 'number'], ['department code', 'text'], ['professor office', 'text'], ['professor extension', 'text'], ['professor high degree', 'text']]
-- Table: student
columns : [['student num', 'number'], ['student last name', 'text'], ['student first name', 'text'], ['student init', 'text'], ['student date of birth', 'time'], ['student class hours took', 'number'], ['student class', 'text'], ['student gpa', 'number'], ['student transfer', 'number'], ['department code', 'text'], ['student phone', 'text'], ['professor number', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `How many different departments are there in each school that has less than 5 apartments?` to a syntactically-correct PostgreSQL query.
| SELECT count(DISTINCT dept_name) , school_code FROM department GROUP BY school_code HAVING count(DISTINCT dept_name) < 5 |
How many sections does each course has? |
-- Language PostgreSQL
-- Tables:
-- Table: class
columns : [['class code', 'text'], ['course code', 'text'], ['class section', 'text'], ['class time', 'text'], ['class room', 'text'], ['professor employee number', 'number']]
-- Table: course
columns : [['course code', 'text'], ['department code', 'text'], ['course description', 'text'], ['course credit', 'number']]
-- Table: department
columns : [['department code', 'text'], ['department name', 'text'], ['school code', 'text'], ['employee number', 'number'], ['department address', 'text'], ['department extension', 'text']]
-- Table: employee
columns : [['employee number', 'number'], ['employee last name', 'text'], ['employee first name', 'text'], ['employee initial', 'text'], ['employee job code', 'text'], ['employee hire date', 'time'], ['employee date of birth', 'time']]
-- Table: enroll
columns : [['class code', 'text'], ['student number', 'number'], ['enroll grade', 'text']]
-- Table: professor
columns : [['employee number', 'number'], ['department code', 'text'], ['professor office', 'text'], ['professor extension', 'text'], ['professor high degree', 'text']]
-- Table: student
columns : [['student num', 'number'], ['student last name', 'text'], ['student first name', 'text'], ['student init', 'text'], ['student date of birth', 'time'], ['student class hours took', 'number'], ['student class', 'text'], ['student gpa', 'number'], ['student transfer', 'number'], ['department code', 'text'], ['student phone', 'text'], ['professor number', 'number']]
You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL.
You should not select columns that are not part of the tables provided to you. Think step by step.
Your only output should be SQL code. Do not include any other text. Only SQL code.
Translate `How many sections does each course has?` to a syntactically-correct PostgreSQL query.
| SELECT count(*) , crs_code FROM CLASS GROUP BY crs_code |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.