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: Tell me the distinct block codes where some rooms are available.
SQL: SELECT DISTINCT blockcode FROM room WHERE unavailable  =  0
-- 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: How many different types of rooms are there?
SQL: SELECT count(DISTINCT roomtype) FROM room
-- 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 number of distinct room types available.
SQL: SELECT count(DISTINCT roomtype) FROM room
-- 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 names of the physicians who prescribe medication Thesisin?
SQL: SELECT DISTINCT T1.name FROM physician AS T1 JOIN prescribes AS T2 ON T1.employeeid = T2.physician JOIN medication AS T3 ON T3.code = T2.medication WHERE T3.name  =  "Thesisin"
-- 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: List the names of all the physicians who prescribe Thesisin as medication.
SQL: SELECT DISTINCT T1.name FROM physician AS T1 JOIN prescribes AS T2 ON T1.employeeid = T2.physician JOIN medication AS T3 ON T3.code = T2.medication WHERE T3.name  =  "Thesisin"
-- 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 and position of physicians who prescribe some medication whose brand is X?
SQL: SELECT DISTINCT T1.name ,  T1.position FROM physician AS T1 JOIN prescribes AS T2 ON T1.employeeid = T2.physician JOIN medication AS T3 ON T3.code = T2.medication WHERE T3.Brand  =  "X"
-- 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 prescribe a medication of brand X? Tell me the name and position of those physicians.
SQL: SELECT DISTINCT T1.name ,  T1.position FROM physician AS T1 JOIN prescribes AS T2 ON T1.employeeid = T2.physician JOIN medication AS T3 ON T3.code = T2.medication WHERE T3.Brand  =  "X"
-- 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 number of medications prescribed for each brand.
SQL: SELECT count(*) ,  T1.name FROM medication AS T1 JOIN prescribes AS T2 ON T1.code = T2.medication GROUP BY T1.brand
-- 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: How many medications are prescribed for each brand?
SQL: SELECT count(*) ,  T1.name FROM medication AS T1 JOIN prescribes AS T2 ON T1.code = T2.medication GROUP BY T1.brand
-- 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 whose position title contains the word 'senior'.
SQL: SELECT name FROM physician WHERE POSITION LIKE '%senior%'
-- 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 the physicians who have 'senior' in their titles.
SQL: SELECT name FROM physician WHERE POSITION LIKE '%senior%'
-- 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 patient who has the most recent undergoing treatment?
SQL: SELECT patient FROM undergoes ORDER BY dateundergoes 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 patient is undergoing the most recent treatment?
SQL: SELECT patient FROM undergoes ORDER BY dateundergoes 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: Find the names of all patients who have an undergoing treatment and are staying in room 111.
SQL: SELECT DISTINCT T2.name FROM undergoes AS T1 JOIN patient AS T2 ON T1.patient = T2.SSN JOIN stay AS T3 ON T1.Stay  =  T3.StayID WHERE T3.room  =  111
-- 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 patients who are staying in room 111 and have an undergoing treatment?
SQL: SELECT DISTINCT T2.name FROM undergoes AS T1 JOIN patient AS T2 ON T1.patient = T2.SSN JOIN stay AS T3 ON T1.Stay  =  T3.StayID WHERE T3.room  =  111
-- 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: List the names of all distinct nurses ordered by alphabetical order?
SQL: SELECT DISTINCT name FROM nurse ORDER BY name
-- 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 alphabetically ordered list of all the distinct names of nurses?
SQL: SELECT DISTINCT name FROM nurse ORDER BY name
-- 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 nurses who are nursing an undergoing treatment.
SQL: SELECT DISTINCT T2.name FROM undergoes AS T1 JOIN nurse AS T2 ON T1.AssistingNurse  =  T2.EmployeeID