sert121/SpiderSQL huggingface dataset:
-- Language PostgreSQL
        -- Tables: 
             -- Table: physician 
columns : [['employee id', 'number'], ['name', 'text'], ['position', 'text'], ['ssn', 'number']]

 -- Table: department 
columns : [['departmentid', 'number'], ['name', 'text'], ['head', 'number']]

 -- Table: affiliated with 
columns : [['physician', 'number'], ['department', 'number'], ['primary affiliation', 'boolean']]

 -- Table: procedures 
columns : [['code', 'number'], ['name', 'text'], ['cost', 'number']]

 -- Table: trained in 
columns : [['physician', 'number'], ['treatment', 'number'], ['certification date', 'time'], ['certification expires', 'time']]

 -- Table: patient 
columns : [['ssn', 'number'], ['name', 'text'], ['address', 'text'], ['phone', 'text'], ['insurance id', 'number'], ['pcp', 'number']]

 -- Table: nurse 
columns : [['employee id', 'number'], ['name', 'text'], ['position', 'text'], ['registered', 'boolean'], ['ssn', 'number']]

 -- Table: appointment 
columns : [['appointment id', 'number'], ['patient', 'number'], ['prep nurse', 'number'], ['physician', 'number'], ['start', 'time'], ['end', 'time'], ['examination room', 'text']]

 -- Table: medication 
columns : [['code', 'number'], ['name', 'text'], ['brand', 'text'], ['description', 'text']]

 -- Table: prescribes 
columns : [['physician', 'number'], ['patient', 'number'], ['medication', 'number'], ['date', 'time'], ['appointment', 'number'], ['dose', 'text']]

 -- Table: block 
columns : [['block floor', 'number'], ['block code', 'number']]

 -- Table: room 
columns : [['roomnumber', 'number'], ['room type', 'text'], ['block floor', 'number'], ['block code', 'number'], ['unavailable', 'boolean']]

 -- Table: on call 
columns : [['nurse', 'number'], ['block floor', 'number'], ['block code', 'number'], ['oncall start', 'time'], ['oncall end', 'time']]

 -- Table: stay 
columns : [['stay id', 'number'], ['patient', 'number'], ['room', 'number'], ['stay start', 'time'], ['stay end', 'time']]

 -- Table: undergoes 
columns : [['patient', 'number'], ['procedures', 'number'], ['stay', 'number'], ['date undergoes', 'time'], ['physician', 'number'], ['assisting nurse', '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: Which physicians are trained in procedures that are more expensive than 5000?
SQL: SELECT T1.name FROM physician AS T1 JOIN trained_in AS T2 ON T1.employeeid  =  T2.physician JOIN procedures AS T3 ON T3.code  =  T2.treatment WHERE T3.cost  >  5000
-- Language PostgreSQL
        -- Tables: 
             -- Table: physician 
columns : [['employee id', 'number'], ['name', 'text'], ['position', 'text'], ['ssn', 'number']]

 -- Table: department 
columns : [['departmentid', 'number'], ['name', 'text'], ['head', 'number']]

 -- Table: affiliated with 
columns : [['physician', 'number'], ['department', 'number'], ['primary affiliation', 'boolean']]

 -- Table: procedures 
columns : [['code', 'number'], ['name', 'text'], ['cost', 'number']]

 -- Table: trained in 
columns : [['physician', 'number'], ['treatment', 'number'], ['certification date', 'time'], ['certification expires', 'time']]

 -- Table: patient 
columns : [['ssn', 'number'], ['name', 'text'], ['address', 'text'], ['phone', 'text'], ['insurance id', 'number'], ['pcp', 'number']]

 -- Table: nurse 
columns : [['employee id', 'number'], ['name', 'text'], ['position', 'text'], ['registered', 'boolean'], ['ssn', 'number']]

 -- Table: appointment 
columns : [['appointment id', 'number'], ['patient', 'number'], ['prep nurse', 'number'], ['physician', 'number'], ['start', 'time'], ['end', 'time'], ['examination room', 'text']]

 -- Table: medication 
columns : [['code', 'number'], ['name', 'text'], ['brand', 'text'], ['description', 'text']]

 -- Table: prescribes 
columns : [['physician', 'number'], ['patient', 'number'], ['medication', 'number'], ['date', 'time'], ['appointment', 'number'], ['dose', 'text']]

 -- Table: block 
columns : [['block floor', 'number'], ['block code', 'number']]

 -- Table: room 
columns : [['roomnumber', 'number'], ['room type', 'text'], ['block floor', 'number'], ['block code', 'number'], ['unavailable', 'boolean']]

 -- Table: on call 
columns : [['nurse', 'number'], ['block floor', 'number'], ['block code', 'number'], ['oncall start', 'time'], ['oncall end', 'time']]

 -- Table: stay 
columns : [['stay id', 'number'], ['patient', 'number'], ['room', 'number'], ['stay start', 'time'], ['stay end', 'time']]

 -- Table: undergoes 
columns : [['patient', 'number'], ['procedures', 'number'], ['stay', 'number'], ['date undergoes', 'time'], ['physician', 'number'], ['assisting nurse', '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 physician who was trained in the most expensive procedure?
SQL: SELECT T1.name FROM physician AS T1 JOIN trained_in AS T2 ON T1.employeeid  =  T2.physician JOIN procedures AS T3 ON T3.code  =  T2.treatment ORDER BY T3.cost DESC LIMIT 1
-- Language PostgreSQL
        -- Tables: 
             -- Table: physician 
columns : [['employee id', 'number'], ['name', 'text'], ['position', 'text'], ['ssn', 'number']]

 -- Table: department 
columns : [['departmentid', 'number'], ['name', 'text'], ['head', 'number']]

 -- Table: affiliated with 
columns : [['physician', 'number'], ['department', 'number'], ['primary affiliation', 'boolean']]

 -- Table: procedures 
columns : [['code', 'number'], ['name', 'text'], ['cost', 'number']]

 -- Table: trained in 
columns : [['physician', 'number'], ['treatment', 'number'], ['certification date', 'time'], ['certification expires', 'time']]

 -- Table: patient 
columns : [['ssn', 'number'], ['name', 'text'], ['address', 'text'], ['phone', 'text'], ['insurance id', 'number'], ['pcp', 'number']]

 -- Table: nurse 
columns : [['employee id', 'number'], ['name', 'text'], ['position', 'text'], ['registered', 'boolean'], ['ssn', 'number']]

 -- Table: appointment 
columns : [['appointment id', 'number'], ['patient', 'number'], ['prep nurse', 'number'], ['physician', 'number'], ['start', 'time'], ['end', 'time'], ['examination room', 'text']]

 -- Table: medication 
columns : [['code', 'number'], ['name', 'text'], ['brand', 'text'], ['description', 'text']]

 -- Table: prescribes 
columns : [['physician', 'number'], ['patient', 'number'], ['medication', 'number'], ['date', 'time'], ['appointment', 'number'], ['dose', 'text']]

 -- Table: block 
columns : [['block floor', 'number'], ['block code', 'number']]

 -- Table: room 
columns : [['roomnumber', 'number'], ['room type', 'text'], ['block floor', 'number'], ['block code', 'number'], ['unavailable', 'boolean']]

 -- Table: on call 
columns : [['nurse', 'number'], ['block floor', 'number'], ['block code', 'number'], ['oncall start', 'time'], ['oncall end', 'time']]

 -- Table: stay 
columns : [['stay id', 'number'], ['patient', 'number'], ['room', 'number'], ['stay start', 'time'], ['stay end', 'time']]

 -- Table: undergoes 
columns : [['patient', 'number'], ['procedures', 'number'], ['stay', 'number'], ['date undergoes', 'time'], ['physician', 'number'], ['assisting nurse', '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: Which physician was trained in the procedure that costs the most.
SQL: SELECT T1.name FROM physician AS T1 JOIN trained_in AS T2 ON T1.employeeid  =  T2.physician JOIN procedures AS T3 ON T3.code  =  T2.treatment ORDER BY T3.cost DESC LIMIT 1
-- Language PostgreSQL
        -- Tables: 
             -- Table: physician 
columns : [['employee id', 'number'], ['name', 'text'], ['position', 'text'], ['ssn', 'number']]

 -- Table: department 
columns : [['departmentid', 'number'], ['name', 'text'], ['head', 'number']]

 -- Table: affiliated with 
columns : [['physician', 'number'], ['department', 'number'], ['primary affiliation', 'boolean']]

 -- Table: procedures 
columns : [['code', 'number'], ['name', 'text'], ['cost', 'number']]

 -- Table: trained in 
columns : [['physician', 'number'], ['treatment', 'number'], ['certification date', 'time'], ['certification expires', 'time']]

 -- Table: patient 
columns : [['ssn', 'number'], ['name', 'text'], ['address', 'text'], ['phone', 'text'], ['insurance id', 'number'], ['pcp', 'number']]

 -- Table: nurse 
columns : [['employee id', 'number'], ['name', 'text'], ['position', 'text'], ['registered', 'boolean'], ['ssn', 'number']]

 -- Table: appointment 
columns : [['appointment id', 'number'], ['patient', 'number'], ['prep nurse', 'number'], ['physician', 'number'], ['start', 'time'], ['end', 'time'], ['examination room', 'text']]

 -- Table: medication 
columns : [['code', 'number'], ['name', 'text'], ['brand', 'text'], ['description', 'text']]

 -- Table: prescribes 
columns : [['physician', 'number'], ['patient', 'number'], ['medication', 'number'], ['date', 'time'], ['appointment', 'number'], ['dose', 'text']]

 -- Table: block 
columns : [['block floor', 'number'], ['block code', 'number']]

 -- Table: room 
columns : [['roomnumber', 'number'], ['room type', 'text'], ['block floor', 'number'], ['block code', 'number'], ['unavailable', 'boolean']]

 -- Table: on call 
columns : [['nurse', 'number'], ['block floor', 'number'], ['block code', 'number'], ['oncall start', 'time'], ['oncall end', 'time']]

 -- Table: stay 
columns : [['stay id', 'number'], ['patient', 'number'], ['room', 'number'], ['stay start', 'time'], ['stay end', 'time']]

 -- Table: undergoes 
columns : [['patient', 'number'], ['procedures', 'number'], ['stay', 'number'], ['date undergoes', 'time'], ['physician', 'number'], ['assisting nurse', '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 average cost of procedures that physician John Wen was trained in?
SQL: SELECT avg(T3.cost) FROM physician AS T1 JOIN trained_in AS T2 ON T1.employeeid  =  T2.physician JOIN procedures AS T3 ON T3.code  =  T2.treatment WHERE T1.name  =  "John Wen"
-- Language PostgreSQL
        -- Tables: 
             -- Table: physician 
columns : [['employee id', 'number'], ['name', 'text'], ['position', 'text'], ['ssn', 'number']]

 -- Table: department 
columns : [['departmentid', 'number'], ['name', 'text'], ['head', 'number']]

 -- Table: affiliated with 
columns : [['physician', 'number'], ['department', 'number'], ['primary affiliation', 'boolean']]

 -- Table: procedures 
columns : [['code', 'number'], ['name', 'text'], ['cost', 'number']]

 -- Table: trained in 
columns : [['physician', 'number'], ['treatment', 'number'], ['certification date', 'time'], ['certification expires', 'time']]

 -- Table: patient 
columns : [['ssn', 'number'], ['name', 'text'], ['address', 'text'], ['phone', 'text'], ['insurance id', 'number'], ['pcp', 'number']]

 -- Table: nurse 
columns : [['employee id', 'number'], ['name', 'text'], ['position', 'text'], ['registered', 'boolean'], ['ssn', 'number']]

 -- Table: appointment 
columns : [['appointment id', 'number'], ['patient', 'number'], ['prep nurse', 'number'], ['physician', 'number'], ['start', 'time'], ['end', 'time'], ['examination room', 'text']]

 -- Table: medication 
columns : [['code', 'number'], ['name', 'text'], ['brand', 'text'], ['description', 'text']]

 -- Table: prescribes 
columns : [['physician', 'number'], ['patient', 'number'], ['medication', 'number'], ['date', 'time'], ['appointment', 'number'], ['dose', 'text']]

 -- Table: block 
columns : [['block floor', 'number'], ['block code', 'number']]

 -- Table: room 
columns : [['roomnumber', 'number'], ['room type', 'text'], ['block floor', 'number'], ['block code', 'number'], ['unavailable', 'boolean']]

 -- Table: on call 
columns : [['nurse', 'number'], ['block floor', 'number'], ['block code', 'number'], ['oncall start', 'time'], ['oncall end', 'time']]

 -- Table: stay 
columns : [['stay id', 'number'], ['patient', 'number'], ['room', 'number'], ['stay start', 'time'], ['stay end', 'time']]

 -- Table: undergoes 
columns : [['patient', 'number'], ['procedures', 'number'], ['stay', 'number'], ['date undergoes', 'time'], ['physician', 'number'], ['assisting nurse', '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: Compute the mean price of procedures physician John Wen was trained in.
SQL: SELECT avg(T3.cost) FROM physician AS T1 JOIN trained_in AS T2 ON T1.employeeid  =  T2.physician JOIN procedures AS T3 ON T3.code  =  T2.treatment WHERE T1.name  =  "John Wen"
-- Language PostgreSQL
        -- Tables: 
             -- Table: physician 
columns : [['employee id', 'number'], ['name', 'text'], ['position', 'text'], ['ssn', 'number']]

 -- Table: department 
columns : [['departmentid', 'number'], ['name', 'text'], ['head', 'number']]

 -- Table: affiliated with 
columns : [['physician', 'number'], ['department', 'number'], ['primary affiliation', 'boolean']]

 -- Table: procedures 
columns : [['code', 'number'], ['name', 'text'], ['cost', 'number']]

 -- Table: trained in 
columns : [['physician', 'number'], ['treatment', 'number'], ['certification date', 'time'], ['certification expires', 'time']]

 -- Table: patient 
columns : [['ssn', 'number'], ['name', 'text'], ['address', 'text'], ['phone', 'text'], ['insurance id', 'number'], ['pcp', 'number']]

 -- Table: nurse 
columns : [['employee id', 'number'], ['name', 'text'], ['position', 'text'], ['registered', 'boolean'], ['ssn', 'number']]

 -- Table: appointment 
columns : [['appointment id', 'number'], ['patient', 'number'], ['prep nurse', 'number'], ['physician', 'number'], ['start', 'time'], ['end', 'time'], ['examination room', 'text']]

 -- Table: medication 
columns : [['code', 'number'], ['name', 'text'], ['brand', 'text'], ['description', 'text']]

 -- Table: prescribes 
columns : [['physician', 'number'], ['patient', 'number'], ['medication', 'number'], ['date', 'time'], ['appointment', 'number'], ['dose', 'text']]

 -- Table: block 
columns : [['block floor', 'number'], ['block code', 'number']]

 -- Table: room 
columns : [['roomnumber', 'number'], ['room type', 'text'], ['block floor', 'number'], ['block code', 'number'], ['unavailable', 'boolean']]

 -- Table: on call 
columns : [['nurse', 'number'], ['block floor', 'number'], ['block code', 'number'], ['oncall start', 'time'], ['oncall end', 'time']]

 -- Table: stay 
columns : [['stay id', 'number'], ['patient', 'number'], ['room', 'number'], ['stay start', 'time'], ['stay end', 'time']]

 -- Table: undergoes 
columns : [['patient', 'number'], ['procedures', 'number'], ['stay', 'number'], ['date undergoes', 'time'], ['physician', 'number'], ['assisting nurse', '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 names of procedures which physician John Wen was trained in.
SQL: SELECT T3.name FROM physician AS T1 JOIN trained_in AS T2 ON T1.employeeid  =  T2.physician JOIN procedures AS T3 ON T3.code  =  T2.treatment WHERE T1.name  =  "John Wen"
-- Language PostgreSQL
        -- Tables: 
             -- Table: physician 
columns : [['employee id', 'number'], ['name', 'text'], ['position', 'text'], ['ssn', 'number']]

 -- Table: department 
columns : [['departmentid', 'number'], ['name', 'text'], ['head', 'number']]

 -- Table: affiliated with 
columns : [['physician', 'number'], ['department', 'number'], ['primary affiliation', 'boolean']]

 -- Table: procedures 
columns : [['code', 'number'], ['name', 'text'], ['cost', 'number']]

 -- Table: trained in 
columns : [['physician', 'number'], ['treatment', 'number'], ['certification date', 'time'], ['certification expires', 'time']]

 -- Table: patient 
columns : [['ssn', 'number'], ['name', 'text'], ['address', 'text'], ['phone', 'text'], ['insurance id', 'number'], ['pcp', 'number']]

 -- Table: nurse 
columns : [['employee id', 'number'], ['name', 'text'], ['position', 'text'], ['registered', 'boolean'], ['ssn', 'number']]

 -- Table: appointment 
columns : [['appointment id', 'number'], ['patient', 'number'], ['prep nurse', 'number'], ['physician', 'number'], ['start', 'time'], ['end', 'time'], ['examination room', 'text']]

 -- Table: medication 
columns : [['code', 'number'], ['name', 'text'], ['brand', 'text'], ['description', 'text']]

 -- Table: prescribes 
columns : [['physician', 'number'], ['patient', 'number'], ['medication', 'number'], ['date', 'time'], ['appointment', 'number'], ['dose', 'text']]

 -- Table: block 
columns : [['block floor', 'number'], ['block code', 'number']]

 -- Table: room 
columns : [['roomnumber', 'number'], ['room type', 'text'], ['block floor', 'number'], ['block code', 'number'], ['unavailable', 'boolean']]

 -- Table: on call 
columns : [['nurse', 'number'], ['block floor', 'number'], ['block code', 'number'], ['oncall start', 'time'], ['oncall end', 'time']]

 -- Table: stay 
columns : [['stay id', 'number'], ['patient', 'number'], ['room', 'number'], ['stay start', 'time'], ['stay end', 'time']]

 -- Table: undergoes 
columns : [['patient', 'number'], ['procedures', 'number'], ['stay', 'number'], ['date undergoes', 'time'], ['physician', 'number'], ['assisting nurse', '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 names of procedures physician John Wen was trained in?
SQL: SELECT T3.name FROM physician AS T1 JOIN trained_in AS T2 ON T1.employeeid  =  T2.physician JOIN procedures AS T3 ON T3.code  =  T2.treatment WHERE T1.name  =  "John Wen"
-- Language PostgreSQL
        -- Tables: 
             -- Table: physician 
columns : [['employee id', 'number'], ['name', 'text'], ['position', 'text'], ['ssn', 'number']]

 -- Table: department 
columns : [['departmentid', 'number'], ['name', 'text'], ['head', 'number']]

 -- Table: affiliated with 
columns : [['physician', 'number'], ['department', 'number'], ['primary affiliation', 'boolean']]

 -- Table: procedures 
columns : [['code', 'number'], ['name', 'text'], ['cost', 'number']]

 -- Table: trained in 
columns : [['physician', 'number'], ['treatment', 'number'], ['certification date', 'time'], ['certification expires', 'time']]

 -- Table: patient 
columns : [['ssn', 'number'], ['name', 'text'], ['address', 'text'], ['phone', 'text'], ['insurance id', 'number'], ['pcp', 'number']]

 -- Table: nurse 
columns : [['employee id', 'number'], ['name', 'text'], ['position', 'text'], ['registered', 'boolean'], ['ssn', 'number']]

 -- Table: appointment 
columns : [['appointment id', 'number'], ['patient', 'number'], ['prep nurse', 'number'], ['physician', 'number'], ['start', 'time'], ['end', 'time'], ['examination room', 'text']]

 -- Table: medication 
columns : [['code', 'number'], ['name', 'text'], ['brand', 'text'], ['description', 'text']]

 -- Table: prescribes 
columns : [['physician', 'number'], ['patient', 'number'], ['medication', 'number'], ['date', 'time'], ['appointment', 'number'], ['dose', 'text']]

 -- Table: block 
columns : [['block floor', 'number'], ['block code', 'number']]

 -- Table: room 
columns : [['roomnumber', 'number'], ['room type', 'text'], ['block floor', 'number'], ['block code', 'number'], ['unavailable', 'boolean']]

 -- Table: on call 
columns : [['nurse', 'number'], ['block floor', 'number'], ['block code', 'number'], ['oncall start', 'time'], ['oncall end', 'time']]

 -- Table: stay 
columns : [['stay id', 'number'], ['patient', 'number'], ['room', 'number'], ['stay start', 'time'], ['stay end', 'time']]

 -- Table: undergoes 
columns : [['patient', 'number'], ['procedures', 'number'], ['stay', 'number'], ['date undergoes', 'time'], ['physician', 'number'], ['assisting nurse', '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 all procedures which cost more than 1000 or which physician John Wen was trained in.
SQL: SELECT name FROM procedures WHERE cost  >  1000 UNION SELECT T3.name FROM physician AS T1 JOIN trained_in AS T2 ON T1.employeeid  =  T2.physician JOIN procedures AS T3 ON T3.code  =  T2.treatment WHERE T1.name  =  "John Wen"
-- Language PostgreSQL
        -- Tables: 
             -- Table: physician 
columns : [['employee id', 'number'], ['name', 'text'], ['position', 'text'], ['ssn', 'number']]

 -- Table: department 
columns : [['departmentid', 'number'], ['name', 'text'], ['head', 'number']]

 -- Table: affiliated with 
columns : [['physician', 'number'], ['department', 'number'], ['primary affiliation', 'boolean']]

 -- Table: procedures 
columns : [['code', 'number'], ['name', 'text'], ['cost', 'number']]

 -- Table: trained in 
columns : [['physician', 'number'], ['treatment', 'number'], ['certification date', 'time'], ['certification expires', 'time']]

 -- Table: patient 
columns : [['ssn', 'number'], ['name', 'text'], ['address', 'text'], ['phone', 'text'], ['insurance id', 'number'], ['pcp', 'number']]

 -- Table: nurse 
columns : [['employee id', 'number'], ['name', 'text'], ['position', 'text'], ['registered', 'boolean'], ['ssn', 'number']]

 -- Table: appointment 
columns : [['appointment id', 'number'], ['patient', 'number'], ['prep nurse', 'number'], ['physician', 'number'], ['start', 'time'], ['end', 'time'], ['examination room', 'text']]

 -- Table: medication 
columns : [['code', 'number'], ['name', 'text'], ['brand', 'text'], ['description', 'text']]

 -- Table: prescribes 
columns : [['physician', 'number'], ['patient', 'number'], ['medication', 'number'], ['date', 'time'], ['appointment', 'number'], ['dose', 'text']]

 -- Table: block 
columns : [['block floor', 'number'], ['block code', 'number']]

 -- Table: room 
columns : [['roomnumber', 'number'], ['room type', 'text'], ['block floor', 'number'], ['block code', 'number'], ['unavailable', 'boolean']]

 -- Table: on call 
columns : [['nurse', 'number'], ['block floor', 'number'], ['block code', 'number'], ['oncall start', 'time'], ['oncall end', 'time']]

 -- Table: stay 
columns : [['stay id', 'number'], ['patient', 'number'], ['room', 'number'], ['stay start', 'time'], ['stay end', 'time']]

 -- Table: undergoes 
columns : [['patient', 'number'], ['procedures', 'number'], ['stay', 'number'], ['date undergoes', 'time'], ['physician', 'number'], ['assisting nurse', '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 procedures that cost more than 1000 or are specialized in by physician John Wen?
SQL: SELECT name FROM procedures WHERE cost  >  1000 UNION SELECT T3.name FROM physician AS T1 JOIN trained_in AS T2 ON T1.employeeid  =  T2.physician JOIN procedures AS T3 ON T3.code  =  T2.treatment WHERE T1.name  =  "John Wen"
-- Language PostgreSQL
        -- Tables: 
             -- Table: physician 
columns : [['employee id', 'number'], ['name', 'text'], ['position', 'text'], ['ssn', 'number']]

 -- Table: department 
columns : [['departmentid', 'number'], ['name', 'text'], ['head', 'number']]

 -- Table: affiliated with 
columns : [['physician', 'number'], ['department', 'number'], ['primary affiliation', 'boolean']]

 -- Table: procedures 
columns : [['code', 'number'], ['name', 'text'], ['cost', 'number']]

 -- Table: trained in 
columns : [['physician', 'number'], ['treatment', 'number'], ['certification date', 'time'], ['certification expires', 'time']]

 -- Table: patient 
columns : [['ssn', 'number'], ['name', 'text'], ['address', 'text'], ['phone', 'text'], ['insurance id', 'number'], ['pcp', 'number']]

 -- Table: nurse 
columns : [['employee id', 'number'], ['name', 'text'], ['position', 'text'], ['registered', 'boolean'], ['ssn', 'number']]

 -- Table: appointment 
columns : [['appointment id', 'number'], ['patient', 'number'], ['prep nurse', 'number'], ['physician', 'number'], ['start', 'time'], ['end', 'time'], ['examination room', 'text']]

 -- Table: medication 
columns : [['code', 'number'], ['name', 'text'], ['brand', 'text'], ['description', 'text']]

 -- Table: prescribes 
columns : [['physician', 'number'], ['patient', 'number'], ['medication', 'number'], ['date', 'time'], ['appointment', 'number'], ['dose', 'text']]

 -- Table: block 
columns : [['block floor', 'number'], ['block code', 'number']]

 -- Table: room 
columns : [['roomnumber', 'number'], ['room type', 'text'], ['block floor', 'number'], ['block code', 'number'], ['unavailable', 'boolean']]

 -- Table: on call 
columns : [['nurse', 'number'], ['block floor', 'number'], ['block code', 'number'], ['oncall start', 'time'], ['oncall end', 'time']]

 -- Table: stay 
columns : [['stay id', 'number'], ['patient', 'number'], ['room', 'number'], ['stay start', 'time'], ['stay end', 'time']]

 -- Table: undergoes 
columns : [['patient', 'number'], ['procedures', 'number'], ['stay', 'number'], ['date undergoes', 'time'], ['physician', 'number'], ['assisting nurse', '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 names of all procedures which cost more than 1000 but which physician John Wen was not trained in?
SQL: SELECT name FROM procedures WHERE cost  >  1000 EXCEPT SELECT T3.name FROM physician AS T1 JOIN trained_in AS T2 ON T1.employeeid  =  T2.physician JOIN procedures AS T3 ON T3.code  =  T2.treatment WHERE T1.name  =  "John Wen"
-- Language PostgreSQL
        -- Tables: 
             -- Table: physician 
columns : [['employee id', 'number'], ['name', 'text'], ['position', 'text'], ['ssn', 'number']]

 -- Table: department 
columns : [['departmentid', 'number'], ['name', 'text'], ['head', 'number']]

 -- Table: affiliated with 
columns : [['physician', 'number'], ['department', 'number'], ['primary affiliation', 'boolean']]

 -- Table: procedures 
columns : [['code', 'number'], ['name', 'text'], ['cost', 'number']]

 -- Table: trained in 
columns : [['physician', 'number'], ['treatment', 'number'], ['certification date', 'time'], ['certification expires', 'time']]

 -- Table: patient 
columns : [['ssn', 'number'], ['name', 'text'], ['address', 'text'], ['phone', 'text'], ['insurance id', 'number'], ['pcp', 'number']]

 -- Table: nurse 
columns : [['employee id', 'number'], ['name', 'text'], ['position', 'text'], ['registered', 'boolean'], ['ssn', 'number']]

 -- Table: appointment 
columns : [['appointment id', 'number'], ['patient', 'number'], ['prep nurse', 'number'], ['physician', 'number'], ['start', 'time'], ['end', 'time'], ['examination room', 'text']]

 -- Table: medication 
columns : [['code', 'number'], ['name', 'text'], ['brand', 'text'], ['description', 'text']]

 -- Table: prescribes 
columns : [['physician', 'number'], ['patient', 'number'], ['medication', 'number'], ['date', 'time'], ['appointment', 'number'], ['dose', 'text']]

 -- Table: block 
columns : [['block floor', 'number'], ['block code', 'number']]

 -- Table: room 
columns : [['roomnumber', 'number'], ['room type', 'text'], ['block floor', 'number'], ['block code', 'number'], ['unavailable', 'boolean']]

 -- Table: on call 
columns : [['nurse', 'number'], ['block floor', 'number'], ['block code', 'number'], ['oncall start', 'time'], ['oncall end', 'time']]

 -- Table: stay 
columns : [['stay id', 'number'], ['patient', 'number'], ['room', 'number'], ['stay start', 'time'], ['stay end', 'time']]

 -- Table: undergoes 
columns : [['patient', 'number'], ['procedures', 'number'], ['stay', 'number'], ['date undergoes', 'time'], ['physician', 'number'], ['assisting nurse', '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: Among the procedures that cost more than 1000, which were not specialized in by physician John Wen?
SQL: SELECT name FROM procedures WHERE cost  >  1000 EXCEPT SELECT T3.name FROM physician AS T1 JOIN trained_in AS T2 ON T1.employeeid  =  T2.physician JOIN procedures AS T3 ON T3.code  =  T2.treatment WHERE T1.name  =  "John Wen"
-- Language PostgreSQL
        -- Tables: 
             -- Table: physician 
columns : [['employee id', 'number'], ['name', 'text'], ['position', 'text'], ['ssn', 'number']]

 -- Table: department 
columns : [['departmentid', 'number'], ['name', 'text'], ['head', 'number']]

 -- Table: affiliated with 
columns : [['physician', 'number'], ['department', 'number'], ['primary affiliation', 'boolean']]

 -- Table: procedures 
columns : [['code', 'number'], ['name', 'text'], ['cost', 'number']]

 -- Table: trained in 
columns : [['physician', 'number'], ['treatment', 'number'], ['certification date', 'time'], ['certification expires', 'time']]

 -- Table: patient 
columns : [['ssn', 'number'], ['name', 'text'], ['address', 'text'], ['phone', 'text'], ['insurance id', 'number'], ['pcp', 'number']]

 -- Table: nurse 
columns : [['employee id', 'number'], ['name', 'text'], ['position', 'text'], ['registered', 'boolean'], ['ssn', 'number']]

 -- Table: appointment 
columns : [['appointment id', 'number'], ['patient', 'number'], ['prep nurse', 'number'], ['physician', 'number'], ['start', 'time'], ['end', 'time'], ['examination room', 'text']]

 -- Table: medication 
columns : [['code', 'number'], ['name', 'text'], ['brand', 'text'], ['description', 'text']]

 -- Table: prescribes 
columns : [['physician', 'number'], ['patient', 'number'], ['medication', 'number'], ['date', 'time'], ['appointment', 'number'], ['dose', 'text']]

 -- Table: block 
columns : [['block floor', 'number'], ['block code', 'number']]

 -- Table: room 
columns : [['roomnumber', 'number'], ['room type', 'text'], ['block floor', 'number'], ['block code', 'number'], ['unavailable', 'boolean']]

 -- Table: on call 
columns : [['nurse', 'number'], ['block floor', 'number'], ['block code', 'number'], ['oncall start', 'time'], ['oncall end', 'time']]

 -- Table: stay 
columns : [['stay id', 'number'], ['patient', 'number'], ['room', 'number'], ['stay start', 'time'], ['stay end', 'time']]

 -- Table: undergoes 
columns : [['patient', 'number'], ['procedures', 'number'], ['stay', 'number'], ['date undergoes', 'time'], ['physician', 'number'], ['assisting nurse', '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 names of all procedures such that the cost is less than 5000 and physician John Wen was trained in.
SQL: SELECT name FROM procedures WHERE cost  <  5000 INTERSECT SELECT T3.name FROM physician AS T1 JOIN trained_in AS T2 ON T1.employeeid  =  T2.physician JOIN procedures AS T3 ON T3.code  =  T2.treatment WHERE T1.name  =  "John Wen"
-- Language PostgreSQL
        -- Tables: 
             -- Table: physician 
columns : [['employee id', 'number'], ['name', 'text'], ['position', 'text'], ['ssn', 'number']]

 -- Table: department 
columns : [['departmentid', 'number'], ['name', 'text'], ['head', 'number']]

 -- Table: affiliated with 
columns : [['physician', 'number'], ['department', 'number'], ['primary affiliation', 'boolean']]

 -- Table: procedures 
columns : [['code', 'number'], ['name', 'text'], ['cost', 'number']]

 -- Table: trained in 
columns : [['physician', 'number'], ['treatment', 'number'], ['certification date', 'time'], ['certification expires', 'time']]

 -- Table: patient 
columns : [['ssn', 'number'], ['name', 'text'], ['address', 'text'], ['phone', 'text'], ['insurance id', 'number'], ['pcp', 'number']]

 -- Table: nurse 
columns : [['employee id', 'number'], ['name', 'text'], ['position', 'text'], ['registered', 'boolean'], ['ssn', 'number']]

 -- Table: appointment 
columns : [['appointment id', 'number'], ['patient', 'number'], ['prep nurse', 'number'], ['physician', 'number'], ['start', 'time'], ['end', 'time'], ['examination room', 'text']]

 -- Table: medication 
columns : [['code', 'number'], ['name', 'text'], ['brand', 'text'], ['description', 'text']]

 -- Table: prescribes 
columns : [['physician', 'number'], ['patient', 'number'], ['medication', 'number'], ['date', 'time'], ['appointment', 'number'], ['dose', 'text']]

 -- Table: block 
columns : [['block floor', 'number'], ['block code', 'number']]

 -- Table: room 
columns : [['roomnumber', 'number'], ['room type', 'text'], ['block floor', 'number'], ['block code', 'number'], ['unavailable', 'boolean']]

 -- Table: on call 
columns : [['nurse', 'number'], ['block floor', 'number'], ['block code', 'number'], ['oncall start', 'time'], ['oncall end', 'time']]

 -- Table: stay 
columns : [['stay id', 'number'], ['patient', 'number'], ['room', 'number'], ['stay start', 'time'], ['stay end', 'time']]

 -- Table: undergoes 
columns : [['patient', 'number'], ['procedures', 'number'], ['stay', 'number'], ['date undergoes', 'time'], ['physician', 'number'], ['assisting nurse', '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 procedures cost less than 5000 and have John Wen as a trained physician?
SQL: SELECT name FROM procedures WHERE cost  <  5000 INTERSECT SELECT T3.name FROM physician AS T1 JOIN trained_in AS T2 ON T1.employeeid  =  T2.physician JOIN procedures AS T3 ON T3.code  =  T2.treatment WHERE T1.name  =  "John Wen"
-- Language PostgreSQL
        -- Tables: 
             -- Table: physician 
columns : [['employee id', 'number'], ['name', 'text'], ['position', 'text'], ['ssn', 'number']]

 -- Table: department 
columns : [['departmentid', 'number'], ['name', 'text'], ['head', 'number']]

 -- Table: affiliated with 
columns : [['physician', 'number'], ['department', 'number'], ['primary affiliation', 'boolean']]

 -- Table: procedures 
columns : [['code', 'number'], ['name', 'text'], ['cost', 'number']]

 -- Table: trained in 
columns : [['physician', 'number'], ['treatment', 'number'], ['certification date', 'time'], ['certification expires', 'time']]

 -- Table: patient 
columns : [['ssn', 'number'], ['name', 'text'], ['address', 'text'], ['phone', 'text'], ['insurance id', 'number'], ['pcp', 'number']]

 -- Table: nurse 
columns : [['employee id', 'number'], ['name', 'text'], ['position', 'text'], ['registered', 'boolean'], ['ssn', 'number']]

 -- Table: appointment 
columns : [['appointment id', 'number'], ['patient', 'number'], ['prep nurse', 'number'], ['physician', 'number'], ['start', 'time'], ['end', 'time'], ['examination room', 'text']]

 -- Table: medication 
columns : [['code', 'number'], ['name', 'text'], ['brand', 'text'], ['description', 'text']]

 -- Table: prescribes 
columns : [['physician', 'number'], ['patient', 'number'], ['medication', 'number'], ['date', 'time'], ['appointment', 'number'], ['dose', 'text']]

 -- Table: block 
columns : [['block floor', 'number'], ['block code', 'number']]

 -- Table: room 
columns : [['roomnumber', 'number'], ['room type', 'text'], ['block floor', 'number'], ['block code', 'number'], ['unavailable', 'boolean']]

 -- Table: on call 
columns : [['nurse', 'number'], ['block floor', 'number'], ['block code', 'number'], ['oncall start', 'time'], ['oncall end', 'time']]

 -- Table: stay 
columns : [['stay id', 'number'], ['patient', 'number'], ['room', 'number'], ['stay start', 'time'], ['stay end', 'time']]

 -- Table: undergoes 
columns : [['patient', 'number'], ['procedures', 'number'], ['stay', 'number'], ['date undergoes', 'time'], ['physician', 'number'], ['assisting nurse', '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 name of physicians who are affiliated with both Surgery and Psychiatry departments.
SQL: SELECT T1.name FROM physician AS T1 JOIN affiliated_with AS T2 ON T1.EmployeeID  =  T2.physician JOIN department AS T3 ON T2.department  =  T3.DepartmentID WHERE T3.name  =  'Surgery' INTERSECT SELECT T1.name FROM physician AS T1 JOIN affiliated_with AS T2 ON T1.EmployeeID  =  T2.physician JOIN department AS T3 ON T2.department  =  T3.DepartmentID WHERE T3.name  =  'Psychiatry'
-- Language PostgreSQL
        -- Tables: 
             -- Table: physician 
columns : [['employee id', 'number'], ['name', 'text'], ['position', 'text'], ['ssn', 'number']]

 -- Table: department 
columns : [['departmentid', 'number'], ['name', 'text'], ['head', 'number']]

 -- Table: affiliated with 
columns : [['physician', 'number'], ['department', 'number'], ['primary affiliation', 'boolean']]

 -- Table: procedures 
columns : [['code', 'number'], ['name', 'text'], ['cost', 'number']]

 -- Table: trained in 
columns : [['physician', 'number'], ['treatment', 'number'], ['certification date', 'time'], ['certification expires', 'time']]

 -- Table: patient 
columns : [['ssn', 'number'], ['name', 'text'], ['address', 'text'], ['phone', 'text'], ['insurance id', 'number'], ['pcp', 'number']]

 -- Table: nurse 
columns : [['employee id', 'number'], ['name', 'text'], ['position', 'text'], ['registered', 'boolean'], ['ssn', 'number']]

 -- Table: appointment 
columns : [['appointment id', 'number'], ['patient', 'number'], ['prep nurse', 'number'], ['physician', 'number'], ['start', 'time'], ['end', 'time'], ['examination room', 'text']]

 -- Table: medication 
columns : [['code', 'number'], ['name', 'text'], ['brand', 'text'], ['description', 'text']]

 -- Table: prescribes 
columns : [['physician', 'number'], ['patient', 'number'], ['medication', 'number'], ['date', 'time'], ['appointment', 'number'], ['dose', 'text']]

 -- Table: block 
columns : [['block floor', 'number'], ['block code', 'number']]

 -- Table: room 
columns : [['roomnumber', 'number'], ['room type', 'text'], ['block floor', 'number'], ['block code', 'number'], ['unavailable', 'boolean']]

 -- Table: on call 
columns : [['nurse', 'number'], ['block floor', 'number'], ['block code', 'number'], ['oncall start', 'time'], ['oncall end', 'time']]

 -- Table: stay 
columns : [['stay id', 'number'], ['patient', 'number'], ['room', 'number'], ['stay start', 'time'], ['stay end', 'time']]

 -- Table: undergoes 
columns : [['patient', 'number'], ['procedures', 'number'], ['stay', 'number'], ['date undergoes', 'time'], ['physician', 'number'], ['assisting nurse', '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: Which physicians are affiliated with both Surgery and Psychiatry departments? Tell me their names.
SQL: SELECT T1.name FROM physician AS T1 JOIN affiliated_with AS T2 ON T1.EmployeeID  =  T2.physician JOIN department AS T3 ON T2.department  =  T3.DepartmentID WHERE T3.name  =  'Surgery' INTERSECT SELECT T1.name FROM physician AS T1 JOIN affiliated_with AS T2 ON T1.EmployeeID  =  T2.physician JOIN department AS T3 ON T2.department  =  T3.DepartmentID WHERE T3.name  =  'Psychiatry'
-- Language PostgreSQL
        -- Tables: 
             -- Table: physician 
columns : [['employee id', 'number'], ['name', 'text'], ['position', 'text'], ['ssn', 'number']]

 -- Table: department 
columns : [['departmentid', 'number'], ['name', 'text'], ['head', 'number']]

 -- Table: affiliated with 
columns : [['physician', 'number'], ['department', 'number'], ['primary affiliation', 'boolean']]

 -- Table: procedures 
columns : [['code', 'number'], ['name', 'text'], ['cost', 'number']]

 -- Table: trained in 
columns : [['physician', 'number'], ['treatment', 'number'], ['certification date', 'time'], ['certification expires', 'time']]

 -- Table: patient 
columns : [['ssn', 'number'], ['name', 'text'], ['address', 'text'], ['phone', 'text'], ['insurance id', 'number'], ['pcp', 'number']]

 -- Table: nurse 
columns : [['employee id', 'number'], ['name', 'text'], ['position', 'text'], ['registered', 'boolean'], ['ssn', 'number']]

 -- Table: appointment 
columns : [['appointment id', 'number'], ['patient', 'number'], ['prep nurse', 'number'], ['physician', 'number'], ['start', 'time'], ['end', 'time'], ['examination room', 'text']]

 -- Table: medication 
columns : [['code', 'number'], ['name', 'text'], ['brand', 'text'], ['description', 'text']]

 -- Table: prescribes 
columns : [['physician', 'number'], ['patient', 'number'], ['medication', 'number'], ['date', 'time'], ['appointment', 'number'], ['dose', 'text']]

 -- Table: block 
columns : [['block floor', 'number'], ['block code', 'number']]

 -- Table: room 
columns : [['roomnumber', 'number'], ['room type', 'text'], ['block floor', 'number'], ['block code', 'number'], ['unavailable', 'boolean']]

 -- Table: on call 
columns : [['nurse', 'number'], ['block floor', 'number'], ['block code', 'number'], ['oncall start', 'time'], ['oncall end', 'time']]

 -- Table: stay 
columns : [['stay id', 'number'], ['patient', 'number'], ['room', 'number'], ['stay start', 'time'], ['stay end', 'time']]

 -- Table: undergoes 
columns : [['patient', 'number'], ['procedures', 'number'], ['stay', 'number'], ['date undergoes', 'time'], ['physician', 'number'], ['assisting nurse', '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 name of physicians who are affiliated with Surgery or Psychiatry department.
SQL: SELECT T1.name FROM physician AS T1 JOIN affiliated_with AS T2 ON T1.EmployeeID  =  T2.physician JOIN department AS T3 ON T2.department  =  T3.DepartmentID WHERE T3.name  =  'Surgery' OR T3.name  =  'Psychiatry'
-- Language PostgreSQL
        -- Tables: 
             -- Table: physician 
columns : [['employee id', 'number'], ['name', 'text'], ['position', 'text'], ['ssn', 'number']]

 -- Table: department 
columns : [['departmentid', 'number'], ['name', 'text'], ['head', 'number']]

 -- Table: affiliated with 
columns : [['physician', 'number'], ['department', 'number'], ['primary affiliation', 'boolean']]

 -- Table: procedures 
columns : [['code', 'number'], ['name', 'text'], ['cost', 'number']]

 -- Table: trained in 
columns : [['physician', 'number'], ['treatment', 'number'], ['certification date', 'time'], ['certification expires', 'time']]

 -- Table: patient 
columns : [['ssn', 'number'], ['name', 'text'], ['address', 'text'], ['phone', 'text'], ['insurance id', 'number'], ['pcp', 'number']]

 -- Table: nurse 
columns : [['employee id', 'number'], ['name', 'text'], ['position', 'text'], ['registered', 'boolean'], ['ssn', 'number']]

 -- Table: appointment 
columns : [['appointment id', 'number'], ['patient', 'number'], ['prep nurse', 'number'], ['physician', 'number'], ['start', 'time'], ['end', 'time'], ['examination room', 'text']]

 -- Table: medication 
columns : [['code', 'number'], ['name', 'text'], ['brand', 'text'], ['description', 'text']]

 -- Table: prescribes 
columns : [['physician', 'number'], ['patient', 'number'], ['medication', 'number'], ['date', 'time'], ['appointment', 'number'], ['dose', 'text']]

 -- Table: block 
columns : [['block floor', 'number'], ['block code', 'number']]

 -- Table: room 
columns : [['roomnumber', 'number'], ['room type', 'text'], ['block floor', 'number'], ['block code', 'number'], ['unavailable', 'boolean']]

 -- Table: on call 
columns : [['nurse', 'number'], ['block floor', 'number'], ['block code', 'number'], ['oncall start', 'time'], ['oncall end', 'time']]

 -- Table: stay 
columns : [['stay id', 'number'], ['patient', 'number'], ['room', 'number'], ['stay start', 'time'], ['stay end', 'time']]

 -- Table: undergoes 
columns : [['patient', 'number'], ['procedures', 'number'], ['stay', 'number'], ['date undergoes', 'time'], ['physician', 'number'], ['assisting nurse', '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: Which physicians are affiliated with either Surgery or Psychiatry department? Give me their names.
SQL: SELECT T1.name FROM physician AS T1 JOIN affiliated_with AS T2 ON T1.EmployeeID  =  T2.physician JOIN department AS T3 ON T2.department  =  T3.DepartmentID WHERE T3.name  =  'Surgery' OR T3.name  =  'Psychiatry'