sert121/SpiderSQL huggingface dataset:
-- Language PostgreSQL
        -- Tables: 
             -- Table: film 
columns : [['film id', 'number'], ['rank in series', 'number'], ['number in season', 'number'], ['title', 'text'], ['directed by', 'text'], ['original air date', 'text'], ['production code', 'text']]

 -- Table: cinema 
columns : [['cinema id', 'number'], ['name', 'text'], ['openning year', 'number'], ['capacity', 'number'], ['location', 'text']]

 -- Table: schedule 
columns : [['cinema id', 'number'], ['film id', 'number'], ['date', 'text'], ['show times per day', 'number'], ['price', '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.



Question: Find the locations that have more than one movie theater with capacity above 300.
SQL: SELECT LOCATION FROM cinema WHERE capacity  >  300 GROUP BY LOCATION HAVING count(*)  >  1
-- Language PostgreSQL
        -- Tables: 
             -- Table: film 
columns : [['film id', 'number'], ['rank in series', 'number'], ['number in season', 'number'], ['title', 'text'], ['directed by', 'text'], ['original air date', 'text'], ['production code', 'text']]

 -- Table: cinema 
columns : [['cinema id', 'number'], ['name', 'text'], ['openning year', 'number'], ['capacity', 'number'], ['location', 'text']]

 -- Table: schedule 
columns : [['cinema id', 'number'], ['film id', 'number'], ['date', 'text'], ['show times per day', 'number'], ['price', '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.



Question: In which locations are there more than one movie theater with capacity above 300?
SQL: SELECT LOCATION FROM cinema WHERE capacity  >  300 GROUP BY LOCATION HAVING count(*)  >  1
-- Language PostgreSQL
        -- Tables: 
             -- Table: film 
columns : [['film id', 'number'], ['rank in series', 'number'], ['number in season', 'number'], ['title', 'text'], ['directed by', 'text'], ['original air date', 'text'], ['production code', 'text']]

 -- Table: cinema 
columns : [['cinema id', 'number'], ['name', 'text'], ['openning year', 'number'], ['capacity', 'number'], ['location', 'text']]

 -- Table: schedule 
columns : [['cinema id', 'number'], ['film id', 'number'], ['date', 'text'], ['show times per day', 'number'], ['price', '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.



Question: How many films have the word 'Dummy' in their titles?
SQL: SELECT count(*) FROM film WHERE title LIKE "%Dummy%"
-- Language PostgreSQL
        -- Tables: 
             -- Table: film 
columns : [['film id', 'number'], ['rank in series', 'number'], ['number in season', 'number'], ['title', 'text'], ['directed by', 'text'], ['original air date', 'text'], ['production code', 'text']]

 -- Table: cinema 
columns : [['cinema id', 'number'], ['name', 'text'], ['openning year', 'number'], ['capacity', 'number'], ['location', 'text']]

 -- Table: schedule 
columns : [['cinema id', 'number'], ['film id', 'number'], ['date', 'text'], ['show times per day', 'number'], ['price', '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.



Question: Count the number of films whose title contains the word 'Dummy'.
SQL: SELECT count(*) FROM film WHERE title LIKE "%Dummy%"
-- Language PostgreSQL
        -- Tables: 
             -- Table: discount coupons 
columns : [['coupon id', 'number'], ['date issued', 'time'], ['coupon amount', 'number']]

 -- Table: customers 
columns : [['customer id', 'number'], ['coupon id', 'number'], ['good or bad customer', 'text'], ['first name', 'text'], ['last name', 'text'], ['gender', 'text'], ['date became customer', 'time'], ['date last hire', 'time']]

 -- Table: bookings 
columns : [['booking id', 'number'], ['customer id', 'number'], ['booking status code', 'text'], ['returned damaged yes or no', 'text'], ['booking start date', 'time'], ['booking end date', 'time'], ['count hired', 'text'], ['amount payable', 'number'], ['amount of discount', 'number'], ['amount outstanding', 'number'], ['amount of refund', 'number']]

 -- Table: products for hire 
columns : [['product id', 'number'], ['product type code', 'text'], ['daily hire cost', 'number'], ['product name', 'text'], ['product description', 'text']]

 -- Table: payments 
columns : [['payment id', 'number'], ['booking id', 'number'], ['customer id', 'number'], ['payment type code', 'text'], ['amount paid in full yn', 'text'], ['payment date', 'time'], ['amount due', 'number'], ['amount paid', 'number']]

 -- Table: products booked 
columns : [['booking id', 'number'], ['product id', 'number'], ['returned yes or no', 'text'], ['returned late yes or no', 'text'], ['booked count', 'number'], ['booked amount', 'number']]

 -- Table: view product availability 
columns : [['product id', 'number'], ['booking id', 'number'], ['status date', 'time'], ['available yes or no', 'text']]

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.



Question: Are the customers holding coupons with amount 500 bad or good?
SQL: SELECT T1.good_or_bad_customer FROM customers AS T1 JOIN discount_coupons AS T2 ON T1.coupon_id  =  T2.coupon_id WHERE T2.coupon_amount  =  500
-- Language PostgreSQL
        -- Tables: 
             -- Table: discount coupons 
columns : [['coupon id', 'number'], ['date issued', 'time'], ['coupon amount', 'number']]

 -- Table: customers 
columns : [['customer id', 'number'], ['coupon id', 'number'], ['good or bad customer', 'text'], ['first name', 'text'], ['last name', 'text'], ['gender', 'text'], ['date became customer', 'time'], ['date last hire', 'time']]

 -- Table: bookings 
columns : [['booking id', 'number'], ['customer id', 'number'], ['booking status code', 'text'], ['returned damaged yes or no', 'text'], ['booking start date', 'time'], ['booking end date', 'time'], ['count hired', 'text'], ['amount payable', 'number'], ['amount of discount', 'number'], ['amount outstanding', 'number'], ['amount of refund', 'number']]

 -- Table: products for hire 
columns : [['product id', 'number'], ['product type code', 'text'], ['daily hire cost', 'number'], ['product name', 'text'], ['product description', 'text']]

 -- Table: payments 
columns : [['payment id', 'number'], ['booking id', 'number'], ['customer id', 'number'], ['payment type code', 'text'], ['amount paid in full yn', 'text'], ['payment date', 'time'], ['amount due', 'number'], ['amount paid', 'number']]

 -- Table: products booked 
columns : [['booking id', 'number'], ['product id', 'number'], ['returned yes or no', 'text'], ['returned late yes or no', 'text'], ['booked count', 'number'], ['booked amount', 'number']]

 -- Table: view product availability 
columns : [['product id', 'number'], ['booking id', 'number'], ['status date', 'time'], ['available yes or no', 'text']]

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.



Question: How many bookings did each customer make? List the customer id, first name, and the count.
SQL: SELECT T1.customer_id ,  T1.first_name ,  count(*) FROM Customers AS T1 JOIN bookings AS T2 ON T1.customer_id  =  T2.customer_id GROUP BY T1.customer_id
-- Language PostgreSQL
        -- Tables: 
             -- Table: discount coupons 
columns : [['coupon id', 'number'], ['date issued', 'time'], ['coupon amount', 'number']]

 -- Table: customers 
columns : [['customer id', 'number'], ['coupon id', 'number'], ['good or bad customer', 'text'], ['first name', 'text'], ['last name', 'text'], ['gender', 'text'], ['date became customer', 'time'], ['date last hire', 'time']]

 -- Table: bookings 
columns : [['booking id', 'number'], ['customer id', 'number'], ['booking status code', 'text'], ['returned damaged yes or no', 'text'], ['booking start date', 'time'], ['booking end date', 'time'], ['count hired', 'text'], ['amount payable', 'number'], ['amount of discount', 'number'], ['amount outstanding', 'number'], ['amount of refund', 'number']]

 -- Table: products for hire 
columns : [['product id', 'number'], ['product type code', 'text'], ['daily hire cost', 'number'], ['product name', 'text'], ['product description', 'text']]

 -- Table: payments 
columns : [['payment id', 'number'], ['booking id', 'number'], ['customer id', 'number'], ['payment type code', 'text'], ['amount paid in full yn', 'text'], ['payment date', 'time'], ['amount due', 'number'], ['amount paid', 'number']]

 -- Table: products booked 
columns : [['booking id', 'number'], ['product id', 'number'], ['returned yes or no', 'text'], ['returned late yes or no', 'text'], ['booked count', 'number'], ['booked amount', 'number']]

 -- Table: view product availability 
columns : [['product id', 'number'], ['booking id', 'number'], ['status date', 'time'], ['available yes or no', 'text']]

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.



Question: What is the maximum total amount paid by a customer? List the customer id and amount.
SQL: SELECT customer_id ,  sum(amount_paid) FROM Payments GROUP BY customer_id ORDER BY sum(amount_paid) DESC LIMIT 1
-- Language PostgreSQL
        -- Tables: 
             -- Table: discount coupons 
columns : [['coupon id', 'number'], ['date issued', 'time'], ['coupon amount', 'number']]

 -- Table: customers 
columns : [['customer id', 'number'], ['coupon id', 'number'], ['good or bad customer', 'text'], ['first name', 'text'], ['last name', 'text'], ['gender', 'text'], ['date became customer', 'time'], ['date last hire', 'time']]

 -- Table: bookings 
columns : [['booking id', 'number'], ['customer id', 'number'], ['booking status code', 'text'], ['returned damaged yes or no', 'text'], ['booking start date', 'time'], ['booking end date', 'time'], ['count hired', 'text'], ['amount payable', 'number'], ['amount of discount', 'number'], ['amount outstanding', 'number'], ['amount of refund', 'number']]

 -- Table: products for hire 
columns : [['product id', 'number'], ['product type code', 'text'], ['daily hire cost', 'number'], ['product name', 'text'], ['product description', 'text']]

 -- Table: payments 
columns : [['payment id', 'number'], ['booking id', 'number'], ['customer id', 'number'], ['payment type code', 'text'], ['amount paid in full yn', 'text'], ['payment date', 'time'], ['amount due', 'number'], ['amount paid', 'number']]

 -- Table: products booked 
columns : [['booking id', 'number'], ['product id', 'number'], ['returned yes or no', 'text'], ['returned late yes or no', 'text'], ['booked count', 'number'], ['booked amount', 'number']]

 -- Table: view product availability 
columns : [['product id', 'number'], ['booking id', 'number'], ['status date', 'time'], ['available yes or no', 'text']]

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.



Question: What are the id and the amount of refund of the booking that incurred the most times of payments?
SQL: SELECT T1.booking_id ,  T1.amount_of_refund FROM Bookings AS T1 JOIN Payments AS T2 ON T1.booking_id  =  T2.booking_id GROUP BY T1.booking_id ORDER BY count(*) DESC LIMIT 1
-- Language PostgreSQL
        -- Tables: 
             -- Table: discount coupons 
columns : [['coupon id', 'number'], ['date issued', 'time'], ['coupon amount', 'number']]

 -- Table: customers 
columns : [['customer id', 'number'], ['coupon id', 'number'], ['good or bad customer', 'text'], ['first name', 'text'], ['last name', 'text'], ['gender', 'text'], ['date became customer', 'time'], ['date last hire', 'time']]

 -- Table: bookings 
columns : [['booking id', 'number'], ['customer id', 'number'], ['booking status code', 'text'], ['returned damaged yes or no', 'text'], ['booking start date', 'time'], ['booking end date', 'time'], ['count hired', 'text'], ['amount payable', 'number'], ['amount of discount', 'number'], ['amount outstanding', 'number'], ['amount of refund', 'number']]

 -- Table: products for hire 
columns : [['product id', 'number'], ['product type code', 'text'], ['daily hire cost', 'number'], ['product name', 'text'], ['product description', 'text']]

 -- Table: payments 
columns : [['payment id', 'number'], ['booking id', 'number'], ['customer id', 'number'], ['payment type code', 'text'], ['amount paid in full yn', 'text'], ['payment date', 'time'], ['amount due', 'number'], ['amount paid', 'number']]

 -- Table: products booked 
columns : [['booking id', 'number'], ['product id', 'number'], ['returned yes or no', 'text'], ['returned late yes or no', 'text'], ['booked count', 'number'], ['booked amount', 'number']]

 -- Table: view product availability 
columns : [['product id', 'number'], ['booking id', 'number'], ['status date', 'time'], ['available yes or no', 'text']]

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.



Question: What is the id of the product that is booked for 3 times?
SQL: SELECT product_id FROM products_booked GROUP BY product_id HAVING count(*)  =  3
-- Language PostgreSQL
        -- Tables: 
             -- Table: discount coupons 
columns : [['coupon id', 'number'], ['date issued', 'time'], ['coupon amount', 'number']]

 -- Table: customers 
columns : [['customer id', 'number'], ['coupon id', 'number'], ['good or bad customer', 'text'], ['first name', 'text'], ['last name', 'text'], ['gender', 'text'], ['date became customer', 'time'], ['date last hire', 'time']]

 -- Table: bookings 
columns : [['booking id', 'number'], ['customer id', 'number'], ['booking status code', 'text'], ['returned damaged yes or no', 'text'], ['booking start date', 'time'], ['booking end date', 'time'], ['count hired', 'text'], ['amount payable', 'number'], ['amount of discount', 'number'], ['amount outstanding', 'number'], ['amount of refund', 'number']]

 -- Table: products for hire 
columns : [['product id', 'number'], ['product type code', 'text'], ['daily hire cost', 'number'], ['product name', 'text'], ['product description', 'text']]

 -- Table: payments 
columns : [['payment id', 'number'], ['booking id', 'number'], ['customer id', 'number'], ['payment type code', 'text'], ['amount paid in full yn', 'text'], ['payment date', 'time'], ['amount due', 'number'], ['amount paid', 'number']]

 -- Table: products booked 
columns : [['booking id', 'number'], ['product id', 'number'], ['returned yes or no', 'text'], ['returned late yes or no', 'text'], ['booked count', 'number'], ['booked amount', 'number']]

 -- Table: view product availability 
columns : [['product id', 'number'], ['booking id', 'number'], ['status date', 'time'], ['available yes or no', 'text']]

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.



Question: What is the product description of the product booked with an amount of 102.76?
SQL: SELECT T2.product_description FROM products_booked AS T1 JOIN products_for_hire AS T2 ON T1.product_id  =  T2.product_id WHERE T1.booked_amount  =  102.76
-- Language PostgreSQL
        -- Tables: 
             -- Table: discount coupons 
columns : [['coupon id', 'number'], ['date issued', 'time'], ['coupon amount', 'number']]

 -- Table: customers 
columns : [['customer id', 'number'], ['coupon id', 'number'], ['good or bad customer', 'text'], ['first name', 'text'], ['last name', 'text'], ['gender', 'text'], ['date became customer', 'time'], ['date last hire', 'time']]

 -- Table: bookings 
columns : [['booking id', 'number'], ['customer id', 'number'], ['booking status code', 'text'], ['returned damaged yes or no', 'text'], ['booking start date', 'time'], ['booking end date', 'time'], ['count hired', 'text'], ['amount payable', 'number'], ['amount of discount', 'number'], ['amount outstanding', 'number'], ['amount of refund', 'number']]

 -- Table: products for hire 
columns : [['product id', 'number'], ['product type code', 'text'], ['daily hire cost', 'number'], ['product name', 'text'], ['product description', 'text']]

 -- Table: payments 
columns : [['payment id', 'number'], ['booking id', 'number'], ['customer id', 'number'], ['payment type code', 'text'], ['amount paid in full yn', 'text'], ['payment date', 'time'], ['amount due', 'number'], ['amount paid', 'number']]

 -- Table: products booked 
columns : [['booking id', 'number'], ['product id', 'number'], ['returned yes or no', 'text'], ['returned late yes or no', 'text'], ['booked count', 'number'], ['booked amount', 'number']]

 -- Table: view product availability 
columns : [['product id', 'number'], ['booking id', 'number'], ['status date', 'time'], ['available yes or no', 'text']]

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.



Question: What are the start date and end date of the booking that has booked the product named 'Book collection A'?
SQL: SELECT T3.booking_start_date ,   T3.booking_end_date FROM Products_for_hire AS T1 JOIN products_booked AS T2 ON T1.product_id  =  T2.product_id JOIN bookings AS T3 ON T2.booking_id  =  T3.booking_id WHERE T1.product_name  =  'Book collection A'
-- Language PostgreSQL
        -- Tables: 
             -- Table: discount coupons 
columns : [['coupon id', 'number'], ['date issued', 'time'], ['coupon amount', 'number']]

 -- Table: customers 
columns : [['customer id', 'number'], ['coupon id', 'number'], ['good or bad customer', 'text'], ['first name', 'text'], ['last name', 'text'], ['gender', 'text'], ['date became customer', 'time'], ['date last hire', 'time']]

 -- Table: bookings 
columns : [['booking id', 'number'], ['customer id', 'number'], ['booking status code', 'text'], ['returned damaged yes or no', 'text'], ['booking start date', 'time'], ['booking end date', 'time'], ['count hired', 'text'], ['amount payable', 'number'], ['amount of discount', 'number'], ['amount outstanding', 'number'], ['amount of refund', 'number']]

 -- Table: products for hire 
columns : [['product id', 'number'], ['product type code', 'text'], ['daily hire cost', 'number'], ['product name', 'text'], ['product description', 'text']]

 -- Table: payments 
columns : [['payment id', 'number'], ['booking id', 'number'], ['customer id', 'number'], ['payment type code', 'text'], ['amount paid in full yn', 'text'], ['payment date', 'time'], ['amount due', 'number'], ['amount paid', 'number']]

 -- Table: products booked 
columns : [['booking id', 'number'], ['product id', 'number'], ['returned yes or no', 'text'], ['returned late yes or no', 'text'], ['booked count', 'number'], ['booked amount', 'number']]

 -- Table: view product availability 
columns : [['product id', 'number'], ['booking id', 'number'], ['status date', 'time'], ['available yes or no', 'text']]

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.



Question: What are the names of products whose availability equals to 1?
SQL: SELECT T2.product_name FROM view_product_availability AS T1 JOIN products_for_hire AS T2 ON T1.product_id  =  T2.product_id WHERE T1.available_yn  =  1
-- Language PostgreSQL
        -- Tables: 
             -- Table: discount coupons 
columns : [['coupon id', 'number'], ['date issued', 'time'], ['coupon amount', 'number']]

 -- Table: customers 
columns : [['customer id', 'number'], ['coupon id', 'number'], ['good or bad customer', 'text'], ['first name', 'text'], ['last name', 'text'], ['gender', 'text'], ['date became customer', 'time'], ['date last hire', 'time']]

 -- Table: bookings 
columns : [['booking id', 'number'], ['customer id', 'number'], ['booking status code', 'text'], ['returned damaged yes or no', 'text'], ['booking start date', 'time'], ['booking end date', 'time'], ['count hired', 'text'], ['amount payable', 'number'], ['amount of discount', 'number'], ['amount outstanding', 'number'], ['amount of refund', 'number']]

 -- Table: products for hire 
columns : [['product id', 'number'], ['product type code', 'text'], ['daily hire cost', 'number'], ['product name', 'text'], ['product description', 'text']]

 -- Table: payments 
columns : [['payment id', 'number'], ['booking id', 'number'], ['customer id', 'number'], ['payment type code', 'text'], ['amount paid in full yn', 'text'], ['payment date', 'time'], ['amount due', 'number'], ['amount paid', 'number']]

 -- Table: products booked 
columns : [['booking id', 'number'], ['product id', 'number'], ['returned yes or no', 'text'], ['returned late yes or no', 'text'], ['booked count', 'number'], ['booked amount', 'number']]

 -- Table: view product availability 
columns : [['product id', 'number'], ['booking id', 'number'], ['status date', 'time'], ['available yes or no', 'text']]

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.



Question: How many different product types are there?
SQL: SELECT count(DISTINCT product_type_code) FROM products_for_hire
-- Language PostgreSQL
        -- Tables: 
             -- Table: discount coupons 
columns : [['coupon id', 'number'], ['date issued', 'time'], ['coupon amount', 'number']]

 -- Table: customers 
columns : [['customer id', 'number'], ['coupon id', 'number'], ['good or bad customer', 'text'], ['first name', 'text'], ['last name', 'text'], ['gender', 'text'], ['date became customer', 'time'], ['date last hire', 'time']]

 -- Table: bookings 
columns : [['booking id', 'number'], ['customer id', 'number'], ['booking status code', 'text'], ['returned damaged yes or no', 'text'], ['booking start date', 'time'], ['booking end date', 'time'], ['count hired', 'text'], ['amount payable', 'number'], ['amount of discount', 'number'], ['amount outstanding', 'number'], ['amount of refund', 'number']]

 -- Table: products for hire 
columns : [['product id', 'number'], ['product type code', 'text'], ['daily hire cost', 'number'], ['product name', 'text'], ['product description', 'text']]

 -- Table: payments 
columns : [['payment id', 'number'], ['booking id', 'number'], ['customer id', 'number'], ['payment type code', 'text'], ['amount paid in full yn', 'text'], ['payment date', 'time'], ['amount due', 'number'], ['amount paid', 'number']]

 -- Table: products booked 
columns : [['booking id', 'number'], ['product id', 'number'], ['returned yes or no', 'text'], ['returned late yes or no', 'text'], ['booked count', 'number'], ['booked amount', 'number']]

 -- Table: view product availability 
columns : [['product id', 'number'], ['booking id', 'number'], ['status date', 'time'], ['available yes or no', 'text']]

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.



Question: What are the first name, last name, and gender of all the good customers? Order by their last name.
SQL: SELECT first_name ,  last_name ,  gender_mf FROM customers WHERE good_or_bad_customer  =  'good' ORDER BY last_name
-- Language PostgreSQL
        -- Tables: 
             -- Table: discount coupons 
columns : [['coupon id', 'number'], ['date issued', 'time'], ['coupon amount', 'number']]

 -- Table: customers 
columns : [['customer id', 'number'], ['coupon id', 'number'], ['good or bad customer', 'text'], ['first name', 'text'], ['last name', 'text'], ['gender', 'text'], ['date became customer', 'time'], ['date last hire', 'time']]

 -- Table: bookings 
columns : [['booking id', 'number'], ['customer id', 'number'], ['booking status code', 'text'], ['returned damaged yes or no', 'text'], ['booking start date', 'time'], ['booking end date', 'time'], ['count hired', 'text'], ['amount payable', 'number'], ['amount of discount', 'number'], ['amount outstanding', 'number'], ['amount of refund', 'number']]

 -- Table: products for hire 
columns : [['product id', 'number'], ['product type code', 'text'], ['daily hire cost', 'number'], ['product name', 'text'], ['product description', 'text']]

 -- Table: payments 
columns : [['payment id', 'number'], ['booking id', 'number'], ['customer id', 'number'], ['payment type code', 'text'], ['amount paid in full yn', 'text'], ['payment date', 'time'], ['amount due', 'number'], ['amount paid', 'number']]

 -- Table: products booked 
columns : [['booking id', 'number'], ['product id', 'number'], ['returned yes or no', 'text'], ['returned late yes or no', 'text'], ['booked count', 'number'], ['booked amount', 'number']]

 -- Table: view product availability 
columns : [['product id', 'number'], ['booking id', 'number'], ['status date', 'time'], ['available yes or no', 'text']]

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.



Question: What is the average amount due for all the payments?
SQL: SELECT avg(amount_due) FROM payments
-- Language PostgreSQL
        -- Tables: 
             -- Table: discount coupons 
columns : [['coupon id', 'number'], ['date issued', 'time'], ['coupon amount', 'number']]

 -- Table: customers 
columns : [['customer id', 'number'], ['coupon id', 'number'], ['good or bad customer', 'text'], ['first name', 'text'], ['last name', 'text'], ['gender', 'text'], ['date became customer', 'time'], ['date last hire', 'time']]

 -- Table: bookings 
columns : [['booking id', 'number'], ['customer id', 'number'], ['booking status code', 'text'], ['returned damaged yes or no', 'text'], ['booking start date', 'time'], ['booking end date', 'time'], ['count hired', 'text'], ['amount payable', 'number'], ['amount of discount', 'number'], ['amount outstanding', 'number'], ['amount of refund', 'number']]

 -- Table: products for hire 
columns : [['product id', 'number'], ['product type code', 'text'], ['daily hire cost', 'number'], ['product name', 'text'], ['product description', 'text']]

 -- Table: payments 
columns : [['payment id', 'number'], ['booking id', 'number'], ['customer id', 'number'], ['payment type code', 'text'], ['amount paid in full yn', 'text'], ['payment date', 'time'], ['amount due', 'number'], ['amount paid', 'number']]

 -- Table: products booked 
columns : [['booking id', 'number'], ['product id', 'number'], ['returned yes or no', 'text'], ['returned late yes or no', 'text'], ['booked count', 'number'], ['booked amount', 'number']]

 -- Table: view product availability 
columns : [['product id', 'number'], ['booking id', 'number'], ['status date', 'time'], ['available yes or no', 'text']]

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.



Question: What are the maximum, minimum, and average booked count for the products booked?
SQL: SELECT max(booked_count) ,  min(booked_count) ,  avg(booked_count) FROM products_booked
-- Language PostgreSQL
        -- Tables: 
             -- Table: discount coupons 
columns : [['coupon id', 'number'], ['date issued', 'time'], ['coupon amount', 'number']]

 -- Table: customers 
columns : [['customer id', 'number'], ['coupon id', 'number'], ['good or bad customer', 'text'], ['first name', 'text'], ['last name', 'text'], ['gender', 'text'], ['date became customer', 'time'], ['date last hire', 'time']]

 -- Table: bookings 
columns : [['booking id', 'number'], ['customer id', 'number'], ['booking status code', 'text'], ['returned damaged yes or no', 'text'], ['booking start date', 'time'], ['booking end date', 'time'], ['count hired', 'text'], ['amount payable', 'number'], ['amount of discount', 'number'], ['amount outstanding', 'number'], ['amount of refund', 'number']]

 -- Table: products for hire 
columns : [['product id', 'number'], ['product type code', 'text'], ['daily hire cost', 'number'], ['product name', 'text'], ['product description', 'text']]

 -- Table: payments 
columns : [['payment id', 'number'], ['booking id', 'number'], ['customer id', 'number'], ['payment type code', 'text'], ['amount paid in full yn', 'text'], ['payment date', 'time'], ['amount due', 'number'], ['amount paid', 'number']]

 -- Table: products booked 
columns : [['booking id', 'number'], ['product id', 'number'], ['returned yes or no', 'text'], ['returned late yes or no', 'text'], ['booked count', 'number'], ['booked amount', 'number']]

 -- Table: view product availability 
columns : [['product id', 'number'], ['booking id', 'number'], ['status date', 'time'], ['available yes or no', 'text']]

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.



Question: What are all the distinct payment types?
SQL: SELECT DISTINCT payment_type_code FROM payments
-- Language PostgreSQL
        -- Tables: 
             -- Table: discount coupons 
columns : [['coupon id', 'number'], ['date issued', 'time'], ['coupon amount', 'number']]

 -- Table: customers 
columns : [['customer id', 'number'], ['coupon id', 'number'], ['good or bad customer', 'text'], ['first name', 'text'], ['last name', 'text'], ['gender', 'text'], ['date became customer', 'time'], ['date last hire', 'time']]

 -- Table: bookings 
columns : [['booking id', 'number'], ['customer id', 'number'], ['booking status code', 'text'], ['returned damaged yes or no', 'text'], ['booking start date', 'time'], ['booking end date', 'time'], ['count hired', 'text'], ['amount payable', 'number'], ['amount of discount', 'number'], ['amount outstanding', 'number'], ['amount of refund', 'number']]

 -- Table: products for hire 
columns : [['product id', 'number'], ['product type code', 'text'], ['daily hire cost', 'number'], ['product name', 'text'], ['product description', 'text']]

 -- Table: payments 
columns : [['payment id', 'number'], ['booking id', 'number'], ['customer id', 'number'], ['payment type code', 'text'], ['amount paid in full yn', 'text'], ['payment date', 'time'], ['amount due', 'number'], ['amount paid', 'number']]

 -- Table: products booked 
columns : [['booking id', 'number'], ['product id', 'number'], ['returned yes or no', 'text'], ['returned late yes or no', 'text'], ['booked count', 'number'], ['booked amount', 'number']]

 -- Table: view product availability 
columns : [['product id', 'number'], ['booking id', 'number'], ['status date', 'time'], ['available yes or no', 'text']]

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.



Question: What are the daily hire costs for the products with substring 'Book' in its name?
SQL: SELECT daily_hire_cost FROM Products_for_hire WHERE product_name LIKE '%Book%'
-- Language PostgreSQL
        -- Tables: 
             -- Table: discount coupons 
columns : [['coupon id', 'number'], ['date issued', 'time'], ['coupon amount', 'number']]

 -- Table: customers 
columns : [['customer id', 'number'], ['coupon id', 'number'], ['good or bad customer', 'text'], ['first name', 'text'], ['last name', 'text'], ['gender', 'text'], ['date became customer', 'time'], ['date last hire', 'time']]

 -- Table: bookings 
columns : [['booking id', 'number'], ['customer id', 'number'], ['booking status code', 'text'], ['returned damaged yes or no', 'text'], ['booking start date', 'time'], ['booking end date', 'time'], ['count hired', 'text'], ['amount payable', 'number'], ['amount of discount', 'number'], ['amount outstanding', 'number'], ['amount of refund', 'number']]

 -- Table: products for hire 
columns : [['product id', 'number'], ['product type code', 'text'], ['daily hire cost', 'number'], ['product name', 'text'], ['product description', 'text']]

 -- Table: payments 
columns : [['payment id', 'number'], ['booking id', 'number'], ['customer id', 'number'], ['payment type code', 'text'], ['amount paid in full yn', 'text'], ['payment date', 'time'], ['amount due', 'number'], ['amount paid', 'number']]

 -- Table: products booked 
columns : [['booking id', 'number'], ['product id', 'number'], ['returned yes or no', 'text'], ['returned late yes or no', 'text'], ['booked count', 'number'], ['booked amount', 'number']]

 -- Table: view product availability 
columns : [['product id', 'number'], ['booking id', 'number'], ['status date', 'time'], ['available yes or no', 'text']]

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.



Question: How many products are never booked with amount higher than 200?
SQL: SELECT count(*) FROM Products_for_hire WHERE product_id NOT IN ( SELECT product_id FROM products_booked WHERE booked_amount  >  200 )
-- Language PostgreSQL
        -- Tables: 
             -- Table: discount coupons 
columns : [['coupon id', 'number'], ['date issued', 'time'], ['coupon amount', 'number']]

 -- Table: customers 
columns : [['customer id', 'number'], ['coupon id', 'number'], ['good or bad customer', 'text'], ['first name', 'text'], ['last name', 'text'], ['gender', 'text'], ['date became customer', 'time'], ['date last hire', 'time']]

 -- Table: bookings 
columns : [['booking id', 'number'], ['customer id', 'number'], ['booking status code', 'text'], ['returned damaged yes or no', 'text'], ['booking start date', 'time'], ['booking end date', 'time'], ['count hired', 'text'], ['amount payable', 'number'], ['amount of discount', 'number'], ['amount outstanding', 'number'], ['amount of refund', 'number']]

 -- Table: products for hire 
columns : [['product id', 'number'], ['product type code', 'text'], ['daily hire cost', 'number'], ['product name', 'text'], ['product description', 'text']]

 -- Table: payments 
columns : [['payment id', 'number'], ['booking id', 'number'], ['customer id', 'number'], ['payment type code', 'text'], ['amount paid in full yn', 'text'], ['payment date', 'time'], ['amount due', 'number'], ['amount paid', 'number']]

 -- Table: products booked 
columns : [['booking id', 'number'], ['product id', 'number'], ['returned yes or no', 'text'], ['returned late yes or no', 'text'], ['booked count', 'number'], ['booked amount', 'number']]

 -- Table: view product availability 
columns : [['product id', 'number'], ['booking id', 'number'], ['status date', 'time'], ['available yes or no', 'text']]

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.



Question: What are the coupon amount of the coupons owned by both good and bad customers?
SQL: SELECT T1.coupon_amount FROM Discount_Coupons AS T1 JOIN customers AS T2 ON T1.coupon_id  =  T2.coupon_id WHERE T2.good_or_bad_customer  =  'good' INTERSECT SELECT T1.coupon_amount FROM Discount_Coupons AS T1 JOIN customers AS T2 ON T1.coupon_id  =  T2.coupon_id WHERE T2.good_or_bad_customer  =  'bad'
-- Language PostgreSQL
        -- Tables: 
             -- Table: discount coupons 
columns : [['coupon id', 'number'], ['date issued', 'time'], ['coupon amount', 'number']]

 -- Table: customers 
columns : [['customer id', 'number'], ['coupon id', 'number'], ['good or bad customer', 'text'], ['first name', 'text'], ['last name', 'text'], ['gender', 'text'], ['date became customer', 'time'], ['date last hire', 'time']]

 -- Table: bookings 
columns : [['booking id', 'number'], ['customer id', 'number'], ['booking status code', 'text'], ['returned damaged yes or no', 'text'], ['booking start date', 'time'], ['booking end date', 'time'], ['count hired', 'text'], ['amount payable', 'number'], ['amount of discount', 'number'], ['amount outstanding', 'number'], ['amount of refund', 'number']]

 -- Table: products for hire 
columns : [['product id', 'number'], ['product type code', 'text'], ['daily hire cost', 'number'], ['product name', 'text'], ['product description', 'text']]

 -- Table: payments 
columns : [['payment id', 'number'], ['booking id', 'number'], ['customer id', 'number'], ['payment type code', 'text'], ['amount paid in full yn', 'text'], ['payment date', 'time'], ['amount due', 'number'], ['amount paid', 'number']]

 -- Table: products booked 
columns : [['booking id', 'number'], ['product id', 'number'], ['returned yes or no', 'text'], ['returned late yes or no', 'text'], ['booked count', 'number'], ['booked amount', 'number']]

 -- Table: view product availability 
columns : [['product id', 'number'], ['booking id', 'number'], ['status date', 'time'], ['available yes or no', 'text']]

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.



Question: What are the payment date of the payment with amount paid higher than 300 or with payment type is 'Check'
SQL: SELECT payment_date FROM payments WHERE amount_paid  >  300 OR payment_type_code  =  'Check'
-- Language PostgreSQL
        -- Tables: 
             -- Table: discount coupons 
columns : [['coupon id', 'number'], ['date issued', 'time'], ['coupon amount', 'number']]

 -- Table: customers 
columns : [['customer id', 'number'], ['coupon id', 'number'], ['good or bad customer', 'text'], ['first name', 'text'], ['last name', 'text'], ['gender', 'text'], ['date became customer', 'time'], ['date last hire', 'time']]

 -- Table: bookings 
columns : [['booking id', 'number'], ['customer id', 'number'], ['booking status code', 'text'], ['returned damaged yes or no', 'text'], ['booking start date', 'time'], ['booking end date', 'time'], ['count hired', 'text'], ['amount payable', 'number'], ['amount of discount', 'number'], ['amount outstanding', 'number'], ['amount of refund', 'number']]

 -- Table: products for hire 
columns : [['product id', 'number'], ['product type code', 'text'], ['daily hire cost', 'number'], ['product name', 'text'], ['product description', 'text']]

 -- Table: payments 
columns : [['payment id', 'number'], ['booking id', 'number'], ['customer id', 'number'], ['payment type code', 'text'], ['amount paid in full yn', 'text'], ['payment date', 'time'], ['amount due', 'number'], ['amount paid', 'number']]

 -- Table: products booked 
columns : [['booking id', 'number'], ['product id', 'number'], ['returned yes or no', 'text'], ['returned late yes or no', 'text'], ['booked count', 'number'], ['booked amount', 'number']]

 -- Table: view product availability 
columns : [['product id', 'number'], ['booking id', 'number'], ['status date', 'time'], ['available yes or no', 'text']]

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.



Question: What are the names and descriptions of the products that are of 'Cutlery' type and have daily hire cost lower than 20?
SQL: SELECT product_name ,  product_description FROM products_for_hire WHERE product_type_code  =  'Cutlery' AND daily_hire_cost  <  20
-- Language PostgreSQL
        -- Tables: 
             -- Table: phone 
columns : [['name', 'text'], ['phone id', 'number'], ['memory in g', 'number'], ['carrier', 'text'], ['price', 'number']]

 -- Table: market 
columns : [['market id', 'number'], ['district', 'text'], ['num of employees', 'number'], ['num of shops', 'number'], ['ranking', 'number']]

 -- Table: phone market 
columns : [['market id', 'number'], ['phone id', 'text'], ['num of stock', '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.



Question: How many phones are there?
SQL: SELECT count(*) FROM phone
-- Language PostgreSQL
        -- Tables: 
             -- Table: phone 
columns : [['name', 'text'], ['phone id', 'number'], ['memory in g', 'number'], ['carrier', 'text'], ['price', 'number']]

 -- Table: market 
columns : [['market id', 'number'], ['district', 'text'], ['num of employees', 'number'], ['num of shops', 'number'], ['ranking', 'number']]

 -- Table: phone market 
columns : [['market id', 'number'], ['phone id', 'text'], ['num of stock', '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.



Question: List the names of phones in ascending order of price.
SQL: SELECT Name FROM phone ORDER BY Price ASC
-- Language PostgreSQL
        -- Tables: 
             -- Table: phone 
columns : [['name', 'text'], ['phone id', 'number'], ['memory in g', 'number'], ['carrier', 'text'], ['price', 'number']]

 -- Table: market 
columns : [['market id', 'number'], ['district', 'text'], ['num of employees', 'number'], ['num of shops', 'number'], ['ranking', 'number']]

 -- Table: phone market 
columns : [['market id', 'number'], ['phone id', 'text'], ['num of stock', '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.



Question: What are the memories and carriers of phones?
SQL: SELECT Memory_in_G ,  Carrier FROM phone
-- Language PostgreSQL
        -- Tables: 
             -- Table: phone 
columns : [['name', 'text'], ['phone id', 'number'], ['memory in g', 'number'], ['carrier', 'text'], ['price', 'number']]

 -- Table: market 
columns : [['market id', 'number'], ['district', 'text'], ['num of employees', 'number'], ['num of shops', 'number'], ['ranking', 'number']]

 -- Table: phone market 
columns : [['market id', 'number'], ['phone id', 'text'], ['num of stock', '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.



Question: List the distinct carriers of phones with memories bigger than 32.
SQL: SELECT DISTINCT Carrier FROM phone WHERE Memory_in_G  >  32
-- Language PostgreSQL
        -- Tables: 
             -- Table: phone 
columns : [['name', 'text'], ['phone id', 'number'], ['memory in g', 'number'], ['carrier', 'text'], ['price', 'number']]

 -- Table: market 
columns : [['market id', 'number'], ['district', 'text'], ['num of employees', 'number'], ['num of shops', 'number'], ['ranking', 'number']]

 -- Table: phone market 
columns : [['market id', 'number'], ['phone id', 'text'], ['num of stock', '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.



Question: Show the names of phones with carrier either "Sprint" or "TMobile".
SQL: SELECT Name FROM phone WHERE Carrier  =  "Sprint" OR Carrier  =  "TMobile"
-- Language PostgreSQL
        -- Tables: 
             -- Table: phone 
columns : [['name', 'text'], ['phone id', 'number'], ['memory in g', 'number'], ['carrier', 'text'], ['price', 'number']]

 -- Table: market 
columns : [['market id', 'number'], ['district', 'text'], ['num of employees', 'number'], ['num of shops', 'number'], ['ranking', 'number']]

 -- Table: phone market 
columns : [['market id', 'number'], ['phone id', 'text'], ['num of stock', '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.



Question: What is the carrier of the most expensive phone?
SQL: SELECT Carrier FROM phone ORDER BY Price DESC LIMIT 1