brief_instruction stringlengths 16 224 | instruction stringlengths 687 8.77k | output stringlengths 18 577 |
|---|---|---|
What is the average gradepoint for students with the last name Smith? |
-- Language PostgreSQL
-- Tables:
-- Table: student
columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']]
-- Table: faculty
columns : [['faculty id', 'number'], ['last name', 'text'], ['first name', 'text'], ['rank', 'text'], ['sex', 'text'], ['phone', 'number'], ['room', 'text'], ['building', 'text']]
-- Table: department
columns : [['department number', 'number'], ['division', 'text'], ['department name', 'text'], ['room', 'text'], ['building', 'text'], ['department phone', 'number']]
-- Table: member of
columns : [['faculty id', 'number'], ['department number', 'number'], ['appt type', 'text']]
-- Table: course
columns : [['course id', 'text'], ['course name', 'text'], ['credits', 'number'], ['instructor', 'number'], ['days', 'text'], ['hours', 'text'], ['department number', 'number']]
-- Table: minor in
columns : [['student id', 'number'], ['department number', 'number']]
-- Table: enrolled in
columns : [['student id', 'number'], ['course id', 'text'], ['grade', 'text']]
-- Table: grade conversion
columns : [['letter grade', 'text'], ['grade point', '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 gradepoint for students with the last name Smith?` to a syntactically-correct PostgreSQL query.
| SELECT avg(T2.gradepoint) FROM ENROLLED_IN AS T1 JOIN GRADECONVERSION AS T2 JOIN STUDENT AS T3 ON T1.Grade = T2.lettergrade AND T1.StuID = T3.StuID WHERE T3.LName = "Smith" |
What is the maximum and minimum grade point of students who live in NYC? |
-- Language PostgreSQL
-- Tables:
-- Table: student
columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']]
-- Table: faculty
columns : [['faculty id', 'number'], ['last name', 'text'], ['first name', 'text'], ['rank', 'text'], ['sex', 'text'], ['phone', 'number'], ['room', 'text'], ['building', 'text']]
-- Table: department
columns : [['department number', 'number'], ['division', 'text'], ['department name', 'text'], ['room', 'text'], ['building', 'text'], ['department phone', 'number']]
-- Table: member of
columns : [['faculty id', 'number'], ['department number', 'number'], ['appt type', 'text']]
-- Table: course
columns : [['course id', 'text'], ['course name', 'text'], ['credits', 'number'], ['instructor', 'number'], ['days', 'text'], ['hours', 'text'], ['department number', 'number']]
-- Table: minor in
columns : [['student id', 'number'], ['department number', 'number']]
-- Table: enrolled in
columns : [['student id', 'number'], ['course id', 'text'], ['grade', 'text']]
-- Table: grade conversion
columns : [['letter grade', 'text'], ['grade point', '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 maximum and minimum grade point of students who live in NYC?` to a syntactically-correct PostgreSQL query.
| SELECT max(T2.gradepoint) , min(T2.gradepoint) FROM ENROLLED_IN AS T1 JOIN GRADECONVERSION AS T2 JOIN STUDENT AS T3 ON T1.Grade = T2.lettergrade AND T1.StuID = T3.StuID WHERE T3.city_code = "NYC" |
Give the maximum and minimum gradepoints for students living in NYC? |
-- Language PostgreSQL
-- Tables:
-- Table: student
columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']]
-- Table: faculty
columns : [['faculty id', 'number'], ['last name', 'text'], ['first name', 'text'], ['rank', 'text'], ['sex', 'text'], ['phone', 'number'], ['room', 'text'], ['building', 'text']]
-- Table: department
columns : [['department number', 'number'], ['division', 'text'], ['department name', 'text'], ['room', 'text'], ['building', 'text'], ['department phone', 'number']]
-- Table: member of
columns : [['faculty id', 'number'], ['department number', 'number'], ['appt type', 'text']]
-- Table: course
columns : [['course id', 'text'], ['course name', 'text'], ['credits', 'number'], ['instructor', 'number'], ['days', 'text'], ['hours', 'text'], ['department number', 'number']]
-- Table: minor in
columns : [['student id', 'number'], ['department number', 'number']]
-- Table: enrolled in
columns : [['student id', 'number'], ['course id', 'text'], ['grade', 'text']]
-- Table: grade conversion
columns : [['letter grade', 'text'], ['grade point', '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 the maximum and minimum gradepoints for students living in NYC?` to a syntactically-correct PostgreSQL query.
| SELECT max(T2.gradepoint) , min(T2.gradepoint) FROM ENROLLED_IN AS T1 JOIN GRADECONVERSION AS T2 JOIN STUDENT AS T3 ON T1.Grade = T2.lettergrade AND T1.StuID = T3.StuID WHERE T3.city_code = "NYC" |
Find the names of courses that have either 3 credits or 1 credit but 4 hours. |
-- Language PostgreSQL
-- Tables:
-- Table: student
columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']]
-- Table: faculty
columns : [['faculty id', 'number'], ['last name', 'text'], ['first name', 'text'], ['rank', 'text'], ['sex', 'text'], ['phone', 'number'], ['room', 'text'], ['building', 'text']]
-- Table: department
columns : [['department number', 'number'], ['division', 'text'], ['department name', 'text'], ['room', 'text'], ['building', 'text'], ['department phone', 'number']]
-- Table: member of
columns : [['faculty id', 'number'], ['department number', 'number'], ['appt type', 'text']]
-- Table: course
columns : [['course id', 'text'], ['course name', 'text'], ['credits', 'number'], ['instructor', 'number'], ['days', 'text'], ['hours', 'text'], ['department number', 'number']]
-- Table: minor in
columns : [['student id', 'number'], ['department number', 'number']]
-- Table: enrolled in
columns : [['student id', 'number'], ['course id', 'text'], ['grade', 'text']]
-- Table: grade conversion
columns : [['letter grade', 'text'], ['grade point', '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 names of courses that have either 3 credits or 1 credit but 4 hours.` to a syntactically-correct PostgreSQL query.
| SELECT CName FROM COURSE WHERE Credits = 3 UNION SELECT CName FROM COURSE WHERE Credits = 1 AND Hours = 4 |
What are the names of courses that give either 3 credits, or 1 credit and 4 hours? |
-- Language PostgreSQL
-- Tables:
-- Table: student
columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']]
-- Table: faculty
columns : [['faculty id', 'number'], ['last name', 'text'], ['first name', 'text'], ['rank', 'text'], ['sex', 'text'], ['phone', 'number'], ['room', 'text'], ['building', 'text']]
-- Table: department
columns : [['department number', 'number'], ['division', 'text'], ['department name', 'text'], ['room', 'text'], ['building', 'text'], ['department phone', 'number']]
-- Table: member of
columns : [['faculty id', 'number'], ['department number', 'number'], ['appt type', 'text']]
-- Table: course
columns : [['course id', 'text'], ['course name', 'text'], ['credits', 'number'], ['instructor', 'number'], ['days', 'text'], ['hours', 'text'], ['department number', 'number']]
-- Table: minor in
columns : [['student id', 'number'], ['department number', 'number']]
-- Table: enrolled in
columns : [['student id', 'number'], ['course id', 'text'], ['grade', 'text']]
-- Table: grade conversion
columns : [['letter grade', 'text'], ['grade point', '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 names of courses that give either 3 credits, or 1 credit and 4 hours?` to a syntactically-correct PostgreSQL query.
| SELECT CName FROM COURSE WHERE Credits = 3 UNION SELECT CName FROM COURSE WHERE Credits = 1 AND Hours = 4 |
Find the names of departments that are either in division AS or in division EN and in Building NEB. |
-- Language PostgreSQL
-- Tables:
-- Table: student
columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']]
-- Table: faculty
columns : [['faculty id', 'number'], ['last name', 'text'], ['first name', 'text'], ['rank', 'text'], ['sex', 'text'], ['phone', 'number'], ['room', 'text'], ['building', 'text']]
-- Table: department
columns : [['department number', 'number'], ['division', 'text'], ['department name', 'text'], ['room', 'text'], ['building', 'text'], ['department phone', 'number']]
-- Table: member of
columns : [['faculty id', 'number'], ['department number', 'number'], ['appt type', 'text']]
-- Table: course
columns : [['course id', 'text'], ['course name', 'text'], ['credits', 'number'], ['instructor', 'number'], ['days', 'text'], ['hours', 'text'], ['department number', 'number']]
-- Table: minor in
columns : [['student id', 'number'], ['department number', 'number']]
-- Table: enrolled in
columns : [['student id', 'number'], ['course id', 'text'], ['grade', 'text']]
-- Table: grade conversion
columns : [['letter grade', 'text'], ['grade point', '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 names of departments that are either in division AS or in division EN and in Building NEB.` to a syntactically-correct PostgreSQL query.
| SELECT DName FROM DEPARTMENT WHERE Division = "AS" UNION SELECT DName FROM DEPARTMENT WHERE Division = "EN" AND Building = "NEB" |
What are the names of departments either in division AS, or in division EN and in building NEB? |
-- Language PostgreSQL
-- Tables:
-- Table: student
columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']]
-- Table: faculty
columns : [['faculty id', 'number'], ['last name', 'text'], ['first name', 'text'], ['rank', 'text'], ['sex', 'text'], ['phone', 'number'], ['room', 'text'], ['building', 'text']]
-- Table: department
columns : [['department number', 'number'], ['division', 'text'], ['department name', 'text'], ['room', 'text'], ['building', 'text'], ['department phone', 'number']]
-- Table: member of
columns : [['faculty id', 'number'], ['department number', 'number'], ['appt type', 'text']]
-- Table: course
columns : [['course id', 'text'], ['course name', 'text'], ['credits', 'number'], ['instructor', 'number'], ['days', 'text'], ['hours', 'text'], ['department number', 'number']]
-- Table: minor in
columns : [['student id', 'number'], ['department number', 'number']]
-- Table: enrolled in
columns : [['student id', 'number'], ['course id', 'text'], ['grade', 'text']]
-- Table: grade conversion
columns : [['letter grade', 'text'], ['grade point', '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 names of departments either in division AS, or in division EN and in building NEB?` to a syntactically-correct PostgreSQL query.
| SELECT DName FROM DEPARTMENT WHERE Division = "AS" UNION SELECT DName FROM DEPARTMENT WHERE Division = "EN" AND Building = "NEB" |
Find the first name of students not enrolled in any course. |
-- Language PostgreSQL
-- Tables:
-- Table: student
columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']]
-- Table: faculty
columns : [['faculty id', 'number'], ['last name', 'text'], ['first name', 'text'], ['rank', 'text'], ['sex', 'text'], ['phone', 'number'], ['room', 'text'], ['building', 'text']]
-- Table: department
columns : [['department number', 'number'], ['division', 'text'], ['department name', 'text'], ['room', 'text'], ['building', 'text'], ['department phone', 'number']]
-- Table: member of
columns : [['faculty id', 'number'], ['department number', 'number'], ['appt type', 'text']]
-- Table: course
columns : [['course id', 'text'], ['course name', 'text'], ['credits', 'number'], ['instructor', 'number'], ['days', 'text'], ['hours', 'text'], ['department number', 'number']]
-- Table: minor in
columns : [['student id', 'number'], ['department number', 'number']]
-- Table: enrolled in
columns : [['student id', 'number'], ['course id', 'text'], ['grade', 'text']]
-- Table: grade conversion
columns : [['letter grade', 'text'], ['grade point', '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 name of students not enrolled in any course.` to a syntactically-correct PostgreSQL query.
| SELECT Fname FROM STUDENT WHERE StuID NOT IN (SELECT StuID FROM ENROLLED_IN) |
What are the first names of all students that are not enrolled in courses? |
-- Language PostgreSQL
-- Tables:
-- Table: student
columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']]
-- Table: faculty
columns : [['faculty id', 'number'], ['last name', 'text'], ['first name', 'text'], ['rank', 'text'], ['sex', 'text'], ['phone', 'number'], ['room', 'text'], ['building', 'text']]
-- Table: department
columns : [['department number', 'number'], ['division', 'text'], ['department name', 'text'], ['room', 'text'], ['building', 'text'], ['department phone', 'number']]
-- Table: member of
columns : [['faculty id', 'number'], ['department number', 'number'], ['appt type', 'text']]
-- Table: course
columns : [['course id', 'text'], ['course name', 'text'], ['credits', 'number'], ['instructor', 'number'], ['days', 'text'], ['hours', 'text'], ['department number', 'number']]
-- Table: minor in
columns : [['student id', 'number'], ['department number', 'number']]
-- Table: enrolled in
columns : [['student id', 'number'], ['course id', 'text'], ['grade', 'text']]
-- Table: grade conversion
columns : [['letter grade', 'text'], ['grade point', '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 of all students that are not enrolled in courses?` to a syntactically-correct PostgreSQL query.
| SELECT Fname FROM STUDENT WHERE StuID NOT IN (SELECT StuID FROM ENROLLED_IN) |
What are the ids of the top three products that were purchased in the largest amount? |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 ids of the top three products that were purchased in the largest amount?` to a syntactically-correct PostgreSQL query.
| SELECT product_id FROM product_suppliers ORDER BY total_amount_purchased DESC LIMIT 3 |
Give the ids of the three products purchased in the largest amounts. |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 the ids of the three products purchased in the largest amounts.` to a syntactically-correct PostgreSQL query.
| SELECT product_id FROM product_suppliers ORDER BY total_amount_purchased DESC LIMIT 3 |
What are the product id and product type of the cheapest product? |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 product id and product type of the cheapest product?` to a syntactically-correct PostgreSQL query.
| SELECT product_id , product_type_code FROM products ORDER BY product_price LIMIT 1 |
Give the id and product type of the product with the lowest price. |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 the id and product type of the product with the lowest price.` to a syntactically-correct PostgreSQL query.
| SELECT product_id , product_type_code FROM products ORDER BY product_price LIMIT 1 |
Find the number of different product types. |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 product types.` to a syntactically-correct PostgreSQL query.
| SELECT count(DISTINCT product_type_code) FROM products |
Count the number of distinct product types. |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 the number of distinct product types.` to a syntactically-correct PostgreSQL query.
| SELECT count(DISTINCT product_type_code) FROM products |
Return the address of customer 10. |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 `Return the address of customer 10.` to a syntactically-correct PostgreSQL query.
| SELECT T1.address_details FROM addresses AS T1 JOIN customer_addresses AS T2 ON T1.address_id = T2.address_id WHERE T2.customer_id = 10 |
What is the address for the customer with id 10? |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 for the customer with id 10?` to a syntactically-correct PostgreSQL query.
| SELECT T1.address_details FROM addresses AS T1 JOIN customer_addresses AS T2 ON T1.address_id = T2.address_id WHERE T2.customer_id = 10 |
What are the staff ids and genders of all staffs whose job title is Department Manager? |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 staff ids and genders of all staffs whose job title is Department Manager?` to a syntactically-correct PostgreSQL query.
| SELECT T1.staff_id , T1.staff_gender FROM staff AS T1 JOIN staff_department_assignments AS T2 ON T1.staff_id = T2.staff_id WHERE T2.job_title_code = "Department Manager" |
Return the staff ids and genders for any staff with the title Department Manager. |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 `Return the staff ids and genders for any staff with the title Department Manager.` to a syntactically-correct PostgreSQL query.
| SELECT T1.staff_id , T1.staff_gender FROM staff AS T1 JOIN staff_department_assignments AS T2 ON T1.staff_id = T2.staff_id WHERE T2.job_title_code = "Department Manager" |
For each payment method, return how many customers use it. |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 each payment method, return how many customers use it.` to a syntactically-correct PostgreSQL query.
| SELECT payment_method_code , count(*) FROM customers GROUP BY payment_method_code |
How many customers use each payment method? |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 customers use each payment method?` to a syntactically-correct PostgreSQL query.
| SELECT payment_method_code , count(*) FROM customers GROUP BY payment_method_code |
What is the id of the product that was ordered the most often? |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 id of the product that was ordered the most often?` to a syntactically-correct PostgreSQL query.
| SELECT product_id FROM order_items GROUP BY product_id ORDER BY count(*) DESC LIMIT 1 |
Give the product id for the product that was ordered most frequently. |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 the product id for the product that was ordered most frequently.` to a syntactically-correct PostgreSQL query.
| SELECT product_id FROM order_items GROUP BY product_id ORDER BY count(*) DESC LIMIT 1 |
What are the name, phone number and email address of the customer who made the largest number of orders? |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 name, phone number and email address of the customer who made the largest number of orders?` to a syntactically-correct PostgreSQL query.
| SELECT T1.customer_name , T1.customer_phone , T1.customer_email FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id GROUP BY T2.customer_id ORDER BY count(*) DESC LIMIT 1 |
Return the name, phone number and email address for the customer with the most orders. |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 `Return the name, phone number and email address for the customer with the most orders.` to a syntactically-correct PostgreSQL query.
| SELECT T1.customer_name , T1.customer_phone , T1.customer_email FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id GROUP BY T2.customer_id ORDER BY count(*) DESC LIMIT 1 |
What is the average price for each type of product? |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 price for each type of product?` to a syntactically-correct PostgreSQL query.
| SELECT product_type_code , avg(product_price) FROM products GROUP BY product_type_code |
Return the average price for each product type. |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 `Return the average price for each product type.` to a syntactically-correct PostgreSQL query.
| SELECT product_type_code , avg(product_price) FROM products GROUP BY product_type_code |
How many department stores does the store chain South have? |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 department stores does the store chain South have?` to a syntactically-correct PostgreSQL query.
| SELECT count(*) FROM department_stores AS T1 JOIN department_store_chain AS T2 ON T1.dept_store_chain_id = T2.dept_store_chain_id WHERE T2.dept_store_chain_name = "South" |
Count the number of stores the chain South has. |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 the number of stores the chain South has.` to a syntactically-correct PostgreSQL query.
| SELECT count(*) FROM department_stores AS T1 JOIN department_store_chain AS T2 ON T1.dept_store_chain_id = T2.dept_store_chain_id WHERE T2.dept_store_chain_name = "South" |
What is the name and job title of the staff who was assigned the latest? |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 job title of the staff who was assigned the latest?` to a syntactically-correct PostgreSQL query.
| SELECT T1.staff_name , T2.job_title_code FROM staff AS T1 JOIN staff_department_assignments AS T2 ON T1.staff_id = T2.staff_id ORDER BY T2.date_assigned_to DESC LIMIT 1 |
Return the name and job title of the staff with the latest date assigned. |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 `Return the name and job title of the staff with the latest date assigned.` to a syntactically-correct PostgreSQL query.
| SELECT T1.staff_name , T2.job_title_code FROM staff AS T1 JOIN staff_department_assignments AS T2 ON T1.staff_id = T2.staff_id ORDER BY T2.date_assigned_to DESC LIMIT 1 |
Give me the product type, name and price for all the products supplied by supplier id 3. |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 product type, name and price for all the products supplied by supplier id 3.` to a syntactically-correct PostgreSQL query.
| SELECT T2.product_type_code , T2.product_name , T2.product_price FROM product_suppliers AS T1 JOIN products AS T2 ON T1.product_id = T2.product_id WHERE T1.supplier_id = 3 |
Return the product type, name, and price for products supplied by supplier 3. |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 `Return the product type, name, and price for products supplied by supplier 3.` to a syntactically-correct PostgreSQL query.
| SELECT T2.product_type_code , T2.product_name , T2.product_price FROM product_suppliers AS T1 JOIN products AS T2 ON T1.product_id = T2.product_id WHERE T1.supplier_id = 3 |
Return the distinct name of customers whose order status is Pending, in the order of customer id. |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 `Return the distinct name of customers whose order status is Pending, in the order of customer id.` to a syntactically-correct PostgreSQL query.
| SELECT DISTINCT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status_code = "Pending" ORDER BY T2.customer_id |
What are the distinct names of customers with an order status of Pending, sorted by customer id? |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 distinct names of customers with an order status of Pending, sorted by customer id?` to a syntactically-correct PostgreSQL query.
| SELECT DISTINCT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status_code = "Pending" ORDER BY T2.customer_id |
Find the name and address of the customers who have both New and Pending orders. |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 and address of the customers who have both New and Pending orders.` to a syntactically-correct PostgreSQL query.
| SELECT T1.customer_name , T1.customer_address FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status_code = "New" INTERSECT SELECT T1.customer_name , T1.customer_address FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status_code = "Pending" |
What are the names and addressed of customers who have both New and Pending orders? |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 names and addressed of customers who have both New and Pending orders?` to a syntactically-correct PostgreSQL query.
| SELECT T1.customer_name , T1.customer_address FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status_code = "New" INTERSECT SELECT T1.customer_name , T1.customer_address FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status_code = "Pending" |
Return ids of all the products that are supplied by supplier id 2 and are more expensive than the average price of all products. |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 `Return ids of all the products that are supplied by supplier id 2 and are more expensive than the average price of all products.` to a syntactically-correct PostgreSQL query.
| SELECT T1.product_id FROM product_suppliers AS T1 JOIN products AS T2 ON T1.product_id = T2.product_id WHERE T1.supplier_id = 2 AND T2.product_price > (SELECT avg(product_price) FROM products) |
What are the ids of products from the supplier with id 2, which are more expensive than the average price across all products? |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 ids of products from the supplier with id 2, which are more expensive than the average price across all products?` to a syntactically-correct PostgreSQL query.
| SELECT T1.product_id FROM product_suppliers AS T1 JOIN products AS T2 ON T1.product_id = T2.product_id WHERE T1.supplier_id = 2 AND T2.product_price > (SELECT avg(product_price) FROM products) |
What is the id and name of the department store that has both marketing and managing department? |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 id and name of the department store that has both marketing and managing department?` to a syntactically-correct PostgreSQL query.
| SELECT T2.dept_store_id , T2.store_name FROM departments AS T1 JOIN department_stores AS T2 ON T1.dept_store_id = T2.dept_store_id WHERE T1.department_name = "marketing" INTERSECT SELECT T2.dept_store_id , T2.store_name FROM departments AS T1 JOIN department_stores AS T2 ON T1.dept_store_id = T2.dept_store_id WHERE T1.department_name = "managing" |
What are the ids and names of department stores with both marketing and managing departments? |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 ids and names of department stores with both marketing and managing departments?` to a syntactically-correct PostgreSQL query.
| SELECT T2.dept_store_id , T2.store_name FROM departments AS T1 JOIN department_stores AS T2 ON T1.dept_store_id = T2.dept_store_id WHERE T1.department_name = "marketing" INTERSECT SELECT T2.dept_store_id , T2.store_name FROM departments AS T1 JOIN department_stores AS T2 ON T1.dept_store_id = T2.dept_store_id WHERE T1.department_name = "managing" |
What are the ids of the two department store chains with the largest number of department stores? |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 ids of the two department store chains with the largest number of department stores?` to a syntactically-correct PostgreSQL query.
| SELECT dept_store_chain_id FROM department_stores GROUP BY dept_store_chain_id ORDER BY count(*) DESC LIMIT 2 |
Return the ids of the two department store chains with the most department stores. |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 `Return the ids of the two department store chains with the most department stores.` to a syntactically-correct PostgreSQL query.
| SELECT dept_store_chain_id FROM department_stores GROUP BY dept_store_chain_id ORDER BY count(*) DESC LIMIT 2 |
What is the id of the department with the least number of staff? |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 id of the department with the least number of staff?` to a syntactically-correct PostgreSQL query.
| SELECT department_id FROM staff_department_assignments GROUP BY department_id ORDER BY count(*) LIMIT 1 |
Return the id of the department with the fewest staff assignments. |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 `Return the id of the department with the fewest staff assignments.` to a syntactically-correct PostgreSQL query.
| SELECT department_id FROM staff_department_assignments GROUP BY department_id ORDER BY count(*) LIMIT 1 |
For each product type, return the maximum and minimum price. |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 each product type, return the maximum and minimum price.` to a syntactically-correct PostgreSQL query.
| SELECT product_type_code , max(product_price) , min(product_price) FROM products GROUP BY product_type_code |
What are the maximum and minimum product prices for each product type? |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 maximum and minimum product prices for each product type?` to a syntactically-correct PostgreSQL query.
| SELECT product_type_code , max(product_price) , min(product_price) FROM products GROUP BY product_type_code |
Find the product type whose average price is higher than the average price of all products. |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 product type whose average price is higher than the average price of all products.` to a syntactically-correct PostgreSQL query.
| SELECT product_type_code FROM products GROUP BY product_type_code HAVING avg(product_price) > (SELECT avg(product_price) FROM products) |
What is the code of the product type with an average price higher than the average price of all products? |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 product type with an average price higher than the average price of all products?` to a syntactically-correct PostgreSQL query.
| SELECT product_type_code FROM products GROUP BY product_type_code HAVING avg(product_price) > (SELECT avg(product_price) FROM products) |
Find the id and name of the staff who has been assigned for the shortest period. |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 name of the staff who has been assigned for the shortest period.` to a syntactically-correct PostgreSQL query.
| SELECT T1.staff_id , T1.staff_name FROM staff AS T1 JOIN Staff_Department_Assignments AS T2 ON T1.staff_id = T2.staff_id ORDER BY date_assigned_to - date_assigned_from LIMIT 1 |
What is the id and name of the staff who has been assigned for the least amount of time? |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 id and name of the staff who has been assigned for the least amount of time?` to a syntactically-correct PostgreSQL query.
| SELECT T1.staff_id , T1.staff_name FROM staff AS T1 JOIN Staff_Department_Assignments AS T2 ON T1.staff_id = T2.staff_id ORDER BY date_assigned_to - date_assigned_from LIMIT 1 |
Return the names and ids of all products whose price is between 600 and 700. |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 `Return the names and ids of all products whose price is between 600 and 700.` to a syntactically-correct PostgreSQL query.
| SELECT product_name , product_id FROM products WHERE product_price BETWEEN 600 AND 700 |
What are the names and ids of products costing between 600 and 700? |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 names and ids of products costing between 600 and 700?` to a syntactically-correct PostgreSQL query.
| SELECT product_name , product_id FROM products WHERE product_price BETWEEN 600 AND 700 |
Find the ids of all distinct customers who made order after some orders that were Cancelled. |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 of all distinct customers who made order after some orders that were Cancelled.` to a syntactically-correct PostgreSQL query.
| SELECT DISTINCT customer_id FROM Customer_Orders WHERE order_date > (SELECT min(order_date) FROM Customer_Orders WHERE order_status_code = "Cancelled") |
What are the distinct ids of customers who made an order after any order that was Cancelled? |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 distinct ids of customers who made an order after any order that was Cancelled?` to a syntactically-correct PostgreSQL query.
| SELECT DISTINCT customer_id FROM Customer_Orders WHERE order_date > (SELECT min(order_date) FROM Customer_Orders WHERE order_status_code = "Cancelled") |
What is id of the staff who had a Staff Department Assignment earlier than any Clerical Staff? |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 id of the staff who had a Staff Department Assignment earlier than any Clerical Staff?` to a syntactically-correct PostgreSQL query.
| SELECT staff_id FROM Staff_Department_Assignments WHERE date_assigned_to < (SELECT max(date_assigned_to) FROM Staff_Department_Assignments WHERE job_title_code = 'Clerical Staff') |
Return the id of the staff whose Staff Department Assignment was earlier than that of any Clerical Staff. |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 `Return the id of the staff whose Staff Department Assignment was earlier than that of any Clerical Staff.` to a syntactically-correct PostgreSQL query.
| SELECT staff_id FROM Staff_Department_Assignments WHERE date_assigned_to < (SELECT max(date_assigned_to) FROM Staff_Department_Assignments WHERE job_title_code = 'Clerical Staff') |
What are the names and ids of customers whose address contains TN? |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 names and ids of customers whose address contains TN?` to a syntactically-correct PostgreSQL query.
| SELECT customer_name , customer_id FROM customers WHERE customer_address LIKE "%TN%" |
Return the names and ids of customers who have TN in their address. |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 `Return the names and ids of customers who have TN in their address.` to a syntactically-correct PostgreSQL query.
| SELECT customer_name , customer_id FROM customers WHERE customer_address LIKE "%TN%" |
Return the name and gender of the staff who was assigned in 2016. |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 `Return the name and gender of the staff who was assigned in 2016.` to a syntactically-correct PostgreSQL query.
| SELECT T1.staff_name , T1.staff_gender FROM staff AS T1 JOIN staff_department_assignments AS T2 ON T1.staff_id = T2.staff_id WHERE T2.date_assigned_from LIKE "2016%" |
What are the names and genders of staff who were assigned in 2016? |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 names and genders of staff who were assigned in 2016?` to a syntactically-correct PostgreSQL query.
| SELECT T1.staff_name , T1.staff_gender FROM staff AS T1 JOIN staff_department_assignments AS T2 ON T1.staff_id = T2.staff_id WHERE T2.date_assigned_from LIKE "2016%" |
List the name of staff who has been assigned multiple jobs. |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 name of staff who has been assigned multiple jobs.` to a syntactically-correct PostgreSQL query.
| SELECT T1.staff_name FROM staff AS T1 JOIN staff_department_assignments AS T2 ON T1.staff_id = T2.staff_id GROUP BY T2.staff_id HAVING COUNT (*) > 1 |
What are the names of staff who have been assigned multiple jobs? |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 names of staff who have been assigned multiple jobs?` to a syntactically-correct PostgreSQL query.
| SELECT T1.staff_name FROM staff AS T1 JOIN staff_department_assignments AS T2 ON T1.staff_id = T2.staff_id GROUP BY T2.staff_id HAVING COUNT (*) > 1 |
List the name and phone number of all suppliers in the alphabetical order of their addresses. |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 name and phone number of all suppliers in the alphabetical order of their addresses.` to a syntactically-correct PostgreSQL query.
| SELECT T1.supplier_name , T1.supplier_phone FROM Suppliers AS T1 JOIN supplier_addresses AS T2 ON T1.supplier_id = T2.supplier_id JOIN addresses AS T3 ON T2.address_id = T3.address_id ORDER BY T3.address_details |
What are the names and phone numbers for all suppliers, sorted in alphabetical order of their addressed? |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 names and phone numbers for all suppliers, sorted in alphabetical order of their addressed?` to a syntactically-correct PostgreSQL query.
| SELECT T1.supplier_name , T1.supplier_phone FROM Suppliers AS T1 JOIN supplier_addresses AS T2 ON T1.supplier_id = T2.supplier_id JOIN addresses AS T3 ON T2.address_id = T3.address_id ORDER BY T3.address_details |
What are the phone numbers of all customers and suppliers. |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 phone numbers of all customers and suppliers.` to a syntactically-correct PostgreSQL query.
| SELECT customer_phone FROM customers UNION SELECT supplier_phone FROM suppliers |
Return the phone numbers for all customers and suppliers. |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 `Return the phone numbers for all customers and suppliers.` to a syntactically-correct PostgreSQL query.
| SELECT customer_phone FROM customers UNION SELECT supplier_phone FROM suppliers |
Return the ids of all products that were ordered more than three times or supplied more than 80000. |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 `Return the ids of all products that were ordered more than three times or supplied more than 80000.` to a syntactically-correct PostgreSQL query.
| SELECT product_id FROM Order_Items GROUP BY product_id HAVING count(*) > 3 UNION SELECT product_id FROM Product_Suppliers GROUP BY product_id HAVING sum(total_amount_purchased) > 80000 |
What are the ids of all products that were either ordered more than 3 times or have a cumulative amount purchased of above 80000? |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 ids of all products that were either ordered more than 3 times or have a cumulative amount purchased of above 80000?` to a syntactically-correct PostgreSQL query.
| SELECT product_id FROM Order_Items GROUP BY product_id HAVING count(*) > 3 UNION SELECT product_id FROM Product_Suppliers GROUP BY product_id HAVING sum(total_amount_purchased) > 80000 |
What are id and name of the products whose price is lower than 600 or higher than 900? |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 id and name of the products whose price is lower than 600 or higher than 900?` to a syntactically-correct PostgreSQL query.
| SELECT product_id , product_name FROM products WHERE product_price < 600 OR product_price > 900 |
Give the ids and names of products with price lower than 600 or higher than 900. |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 the ids and names of products with price lower than 600 or higher than 900.` to a syntactically-correct PostgreSQL query.
| SELECT product_id , product_name FROM products WHERE product_price < 600 OR product_price > 900 |
Find the id of suppliers whose average amount purchased for each product is above 50000 or below 30000. |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 of suppliers whose average amount purchased for each product is above 50000 or below 30000.` to a syntactically-correct PostgreSQL query.
| SELECT supplier_id FROM Product_Suppliers GROUP BY supplier_id HAVING avg(total_amount_purchased) > 50000 OR avg(total_amount_purchased) < 30000 |
What are the ids of suppliers which have an average amount purchased of above 50000 or below 30000? |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 ids of suppliers which have an average amount purchased of above 50000 or below 30000?` to a syntactically-correct PostgreSQL query.
| SELECT supplier_id FROM Product_Suppliers GROUP BY supplier_id HAVING avg(total_amount_purchased) > 50000 OR avg(total_amount_purchased) < 30000 |
What are the average amount purchased and value purchased for the supplier who supplies the most products. |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 average amount purchased and value purchased for the supplier who supplies the most products.` to a syntactically-correct PostgreSQL query.
| SELECT avg(total_amount_purchased) , avg(total_value_purchased) FROM Product_Suppliers WHERE supplier_id = (SELECT supplier_id FROM Product_Suppliers GROUP BY supplier_id ORDER BY count(*) DESC LIMIT 1) |
Return the average total amount purchased and total value purchased for the supplier who supplies the greatest number of products. |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 `Return the average total amount purchased and total value purchased for the supplier who supplies the greatest number of products.` to a syntactically-correct PostgreSQL query.
| SELECT avg(total_amount_purchased) , avg(total_value_purchased) FROM Product_Suppliers WHERE supplier_id = (SELECT supplier_id FROM Product_Suppliers GROUP BY supplier_id ORDER BY count(*) DESC LIMIT 1) |
What is the largest and smallest customer codes? |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 largest and smallest customer codes?` to a syntactically-correct PostgreSQL query.
| SELECT max(customer_code) , min(customer_code) FROM Customers |
Return the maximum and minimum customer codes. |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 `Return the maximum and minimum customer codes.` to a syntactically-correct PostgreSQL query.
| SELECT max(customer_code) , min(customer_code) FROM Customers |
List the names of all the distinct customers who bought a keyboard. |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 names of all the distinct customers who bought a keyboard.` to a syntactically-correct PostgreSQL query.
| SELECT DISTINCT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id JOIN order_items AS T3 ON T2.order_id = T3.order_id JOIN products AS T4 ON T3.product_id = T4.product_id WHERE T4.product_name = "keyboard" |
What are the distinct names of customers who have purchased a keyboard? |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 distinct names of customers who have purchased a keyboard?` to a syntactically-correct PostgreSQL query.
| SELECT DISTINCT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id JOIN order_items AS T3 ON T2.order_id = T3.order_id JOIN products AS T4 ON T3.product_id = T4.product_id WHERE T4.product_name = "keyboard" |
List the names and phone numbers of all the distinct suppliers who supply red jeans. |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 names and phone numbers of all the distinct suppliers who supply red jeans.` to a syntactically-correct PostgreSQL query.
| SELECT DISTINCT T1.supplier_name , T1.supplier_phone FROM suppliers AS T1 JOIN product_suppliers AS T2 ON T1.supplier_id = T2.supplier_id JOIN products AS T3 ON T2.product_id = T3.product_id WHERE T3.product_name = "red jeans" |
What are the distinct names and phone numbers for suppliers who have red jeans? |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 distinct names and phone numbers for suppliers who have red jeans?` to a syntactically-correct PostgreSQL query.
| SELECT DISTINCT T1.supplier_name , T1.supplier_phone FROM suppliers AS T1 JOIN product_suppliers AS T2 ON T1.supplier_id = T2.supplier_id JOIN products AS T3 ON T2.product_id = T3.product_id WHERE T3.product_name = "red jeans" |
What are the highest and lowest prices of products, grouped by and alphabetically ordered by product type? |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 highest and lowest prices of products, grouped by and alphabetically ordered by product type?` to a syntactically-correct PostgreSQL query.
| SELECT max(product_price) , min(product_price) , product_type_code FROM products GROUP BY product_type_code ORDER BY product_type_code |
Give the maximum and minimum product prices for each product type, grouped and ordered by product type. |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 the maximum and minimum product prices for each product type, grouped and ordered by product type.` to a syntactically-correct PostgreSQL query.
| SELECT max(product_price) , min(product_price) , product_type_code FROM products GROUP BY product_type_code ORDER BY product_type_code |
List the order id, customer id for orders in Cancelled status, ordered by their order dates. |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 order id, customer id for orders in Cancelled status, ordered by their order dates.` to a syntactically-correct PostgreSQL query.
| SELECT order_id , customer_id FROM customer_orders WHERE order_status_code = "Cancelled" ORDER BY order_date |
What are the order ids and customer ids for orders that have been Cancelled, sorted by their order dates? |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 order ids and customer ids for orders that have been Cancelled, sorted by their order dates?` to a syntactically-correct PostgreSQL query.
| SELECT order_id , customer_id FROM customer_orders WHERE order_status_code = "Cancelled" ORDER BY order_date |
Find the names of products that were bought by at least two distinct customers. |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 names of products that were bought by at least two distinct customers.` to a syntactically-correct PostgreSQL query.
| SELECT DISTINCT T3.product_name FROM customer_orders AS T1 JOIN order_items AS T2 ON T1.order_id = T2.order_id JOIN products AS T3 ON T2.product_id = T3.product_id GROUP BY T3.product_id HAVING COUNT (DISTINCT T1.customer_id) >= 2 |
What are the distinct names of products purchased by at least two different customers? |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 distinct names of products purchased by at least two different customers?` to a syntactically-correct PostgreSQL query.
| SELECT DISTINCT T3.product_name FROM customer_orders AS T1 JOIN order_items AS T2 ON T1.order_id = T2.order_id JOIN products AS T3 ON T2.product_id = T3.product_id GROUP BY T3.product_id HAVING COUNT (DISTINCT T1.customer_id) >= 2 |
Find the names of customers who have bought by at least three distinct products. |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 names of customers who have bought by at least three distinct products.` to a syntactically-correct PostgreSQL query.
| SELECT DISTINCT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id JOIN order_items AS T3 ON T2.order_id = T3.order_id GROUP BY T1.customer_id HAVING COUNT (DISTINCT T3.product_id) >= 3 |
What are the distinct names of customers who have purchased at least three different products? |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 distinct names of customers who have purchased at least three different products?` to a syntactically-correct PostgreSQL query.
| SELECT DISTINCT T1.customer_name FROM customers AS T1 JOIN customer_orders AS T2 ON T1.customer_id = T2.customer_id JOIN order_items AS T3 ON T2.order_id = T3.order_id GROUP BY T1.customer_id HAVING COUNT (DISTINCT T3.product_id) >= 3 |
Find the name and gender of the staff who has been assigned the job of Sales Person but never Clerical Staff. |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 and gender of the staff who has been assigned the job of Sales Person but never Clerical Staff.` to a syntactically-correct PostgreSQL query.
| SELECT T1.staff_name , T1.staff_gender FROM staff AS T1 JOIN Staff_Department_Assignments AS T2 ON T1.staff_id = T2.staff_id WHERE T2.job_title_code = "Sales Person" EXCEPT SELECT T1.staff_name , T1.staff_gender FROM staff AS T1 JOIN Staff_Department_Assignments AS T2 ON T1.staff_id = T2.staff_id WHERE T2.job_title_code = "Clerical Staff" |
What are the names and genders of staff who have held the title Sales Person, but never Clerical Staff? |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 names and genders of staff who have held the title Sales Person, but never Clerical Staff?` to a syntactically-correct PostgreSQL query.
| SELECT T1.staff_name , T1.staff_gender FROM staff AS T1 JOIN Staff_Department_Assignments AS T2 ON T1.staff_id = T2.staff_id WHERE T2.job_title_code = "Sales Person" EXCEPT SELECT T1.staff_name , T1.staff_gender FROM staff AS T1 JOIN Staff_Department_Assignments AS T2 ON T1.staff_id = T2.staff_id WHERE T2.job_title_code = "Clerical Staff" |
Find the id and name of customers whose address contains WY state and do not use credit card for payment. |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 name of customers whose address contains WY state and do not use credit card for payment.` to a syntactically-correct PostgreSQL query.
| SELECT customer_id , customer_name FROM customers WHERE customer_address LIKE "%WY%" AND payment_method_code != "Credit Card" |
What are the ids and names of customers with addressed that contain WY and who do not use a credit card for payment? |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 ids and names of customers with addressed that contain WY and who do not use a credit card for payment?` to a syntactically-correct PostgreSQL query.
| SELECT customer_id , customer_name FROM customers WHERE customer_address LIKE "%WY%" AND payment_method_code != "Credit Card" |
Find the average price of all product clothes. |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 average price of all product clothes.` to a syntactically-correct PostgreSQL query.
| SELECT avg(product_price) FROM products WHERE product_type_code = 'Clothes' |
What is the average price of clothes? |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 price of clothes?` to a syntactically-correct PostgreSQL query.
| SELECT avg(product_price) FROM products WHERE product_type_code = 'Clothes' |
Find the name of the most expensive hardware product. |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 most expensive hardware product.` to a syntactically-correct PostgreSQL query.
| SELECT product_name FROM products WHERE product_type_code = 'Hardware' ORDER BY product_price DESC LIMIT 1 |
What is the name of the hardware product with the greatest price? |
-- Language PostgreSQL
-- Tables:
-- Table: addresses
columns : [['address id', 'number'], ['address details', 'text']]
-- Table: staff
columns : [['staff id', 'number'], ['staff gender', 'text'], ['staff name', 'text']]
-- Table: suppliers
columns : [['supplier id', 'number'], ['supplier name', 'text'], ['supplier phone', 'text']]
-- Table: department store chain
columns : [['department store chain id', 'number'], ['department store chain name', 'text']]
-- Table: customers
columns : [['customer id', 'number'], ['payment method code', 'text'], ['customer code', 'text'], ['customer name', 'text'], ['customer address', 'text'], ['customer phone', 'text'], ['customer email', 'text']]
-- Table: products
columns : [['product id', 'number'], ['product type code', 'text'], ['product name', 'text'], ['product price', 'number']]
-- Table: supplier addresses
columns : [['supplier id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer addresses
columns : [['customer id', 'number'], ['address id', 'number'], ['date from', 'time'], ['date to', 'time']]
-- Table: customer orders
columns : [['order id', 'number'], ['customer id', 'number'], ['order status code', 'text'], ['order date', 'time']]
-- Table: department stores
columns : [['department store id', 'number'], ['department store chain id', 'number'], ['store name', 'text'], ['store address', 'text'], ['store phone', 'text'], ['store email', 'text']]
-- Table: departments
columns : [['department id', 'number'], ['department store id', 'number'], ['department name', 'text']]
-- Table: order items
columns : [['order item id', 'number'], ['order id', 'number'], ['product id', 'number']]
-- Table: product suppliers
columns : [['product id', 'number'], ['supplier id', 'number'], ['date supplied from', 'time'], ['date supplied to', 'time'], ['total amount purchased', 'text'], ['total value purchased', 'number']]
-- Table: staff department assignments
columns : [['staff id', 'number'], ['department id', 'number'], ['date assigned from', 'time'], ['job title code', 'text'], ['date assigned to', 'time']]
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 of the hardware product with the greatest price?` to a syntactically-correct PostgreSQL query.
| SELECT product_name FROM products WHERE product_type_code = 'Hardware' ORDER BY product_price DESC LIMIT 1 |
How many aircrafts are there? |
-- Language PostgreSQL
-- Tables:
-- Table: pilot
columns : [['pilot id', 'number'], ['name', 'text'], ['age', 'number']]
-- Table: aircraft
columns : [['aircraft id', 'number'], ['aircraft', 'text'], ['description', 'text'], ['max gross weight', 'text'], ['total disk area', 'text'], ['max disk loading', 'text']]
-- Table: match
columns : [['round', 'number'], ['location', 'text'], ['country', 'text'], ['date', 'text'], ['fastest qualifying', 'text'], ['winning pilot', 'text'], ['winning aircraft', 'text']]
-- Table: airport
columns : [['airport id', 'number'], ['airport name', 'text'], ['total passengers', 'number'], ['% change 2007', 'text'], ['international passengers', 'number'], ['domestic passengers', 'number'], ['transit passengers', 'number'], ['aircraft movements', 'number'], ['freight metric tonnes', 'number']]
-- Table: airport aircraft
columns : [['id', 'number'], ['airport id', 'number'], ['aircraft 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 aircrafts are there?` to a syntactically-correct PostgreSQL query.
| SELECT count(*) FROM aircraft |
What is the number of aircraft? |
-- Language PostgreSQL
-- Tables:
-- Table: pilot
columns : [['pilot id', 'number'], ['name', 'text'], ['age', 'number']]
-- Table: aircraft
columns : [['aircraft id', 'number'], ['aircraft', 'text'], ['description', 'text'], ['max gross weight', 'text'], ['total disk area', 'text'], ['max disk loading', 'text']]
-- Table: match
columns : [['round', 'number'], ['location', 'text'], ['country', 'text'], ['date', 'text'], ['fastest qualifying', 'text'], ['winning pilot', 'text'], ['winning aircraft', 'text']]
-- Table: airport
columns : [['airport id', 'number'], ['airport name', 'text'], ['total passengers', 'number'], ['% change 2007', 'text'], ['international passengers', 'number'], ['domestic passengers', 'number'], ['transit passengers', 'number'], ['aircraft movements', 'number'], ['freight metric tonnes', 'number']]
-- Table: airport aircraft
columns : [['id', 'number'], ['airport id', 'number'], ['aircraft 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 number of aircraft?` to a syntactically-correct PostgreSQL query.
| SELECT count(*) FROM aircraft |
List the description of all aircrafts. |
-- Language PostgreSQL
-- Tables:
-- Table: pilot
columns : [['pilot id', 'number'], ['name', 'text'], ['age', 'number']]
-- Table: aircraft
columns : [['aircraft id', 'number'], ['aircraft', 'text'], ['description', 'text'], ['max gross weight', 'text'], ['total disk area', 'text'], ['max disk loading', 'text']]
-- Table: match
columns : [['round', 'number'], ['location', 'text'], ['country', 'text'], ['date', 'text'], ['fastest qualifying', 'text'], ['winning pilot', 'text'], ['winning aircraft', 'text']]
-- Table: airport
columns : [['airport id', 'number'], ['airport name', 'text'], ['total passengers', 'number'], ['% change 2007', 'text'], ['international passengers', 'number'], ['domestic passengers', 'number'], ['transit passengers', 'number'], ['aircraft movements', 'number'], ['freight metric tonnes', 'number']]
-- Table: airport aircraft
columns : [['id', 'number'], ['airport id', 'number'], ['aircraft 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 description of all aircrafts.` to a syntactically-correct PostgreSQL query.
| SELECT Description FROM aircraft |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.