richardr1126/spider-context-instruct huggingface dataset:
### Instruction:

Convert text to sql: How many services has each resident requested? List the resident id, details, and the count in descending order of the count. | customers : customer_id , customer_details | properties : property_id , property_type_code , property_address , other_details | residents : resident_id , property_id , date_moved_in , date_moved_out , other_details | organizations : organization_id , parent_organization_id , organization_details | services : service_id , organization_id , service_type_code , service_details | residents_services : resident_id , service_id , date_moved_in , property_id , date_requested , date_provided , other_details | things : thing_id , organization_id , type_of_thing_code , service_type_code , service_details | customer_events : customer_event_id , customer_id , date_moved_in , property_id , resident_id , thing_id | customer_event_notes : customer_event_note_id , customer_event_id , service_type_code , resident_id , property_id , date_moved_in | timed_status_of_things : thing_id , date_and_date , status_of_thing_code | timed_locations_of_things : thing_id , date_and_time , location_code | residents.property_id = properties.property_id | services.organization_id = organizations.organization_id | residents_services.resident_id = residents.resident_id | residents_services.property_id = residents.property_id | residents_services.date_moved_in = residents.date_moved_in | residents_services.service_id = services.service_id | things.organization_id = organizations.organization_id | customer_events.resident_id = residents.resident_id | customer_events.property_id = residents.property_id | customer_events.date_moved_in = residents.date_moved_in | customer_events.customer_id = customers.customer_id | customer_events.thing_id = things.thing_id | customer_event_notes.customer_event_id = customer_events.customer_event_id | timed_status_of_things.thing_id = things.thing_id | timed_locations_of_things.thing_id = things.thing_id | 

### Response:

select residents.resident_id , residents.other_details , count ( * ) from residents join residents_services on residents.resident_id = residents_services.resident_id group by residents.resident_id order by count ( * ) desc
### Instruction:

Convert text to sql: What is the maximum number that a certain service is provided? List the service id, details and number. | customers : customer_id , customer_details | properties : property_id , property_type_code , property_address , other_details | residents : resident_id , property_id , date_moved_in , date_moved_out , other_details | organizations : organization_id , parent_organization_id , organization_details | services : service_id , organization_id , service_type_code , service_details | residents_services : resident_id , service_id , date_moved_in , property_id , date_requested , date_provided , other_details | things : thing_id , organization_id , type_of_thing_code , service_type_code , service_details | customer_events : customer_event_id , customer_id , date_moved_in , property_id , resident_id , thing_id | customer_event_notes : customer_event_note_id , customer_event_id , service_type_code , resident_id , property_id , date_moved_in | timed_status_of_things : thing_id , date_and_date , status_of_thing_code | timed_locations_of_things : thing_id , date_and_time , location_code | residents.property_id = properties.property_id | services.organization_id = organizations.organization_id | residents_services.resident_id = residents.resident_id | residents_services.property_id = residents.property_id | residents_services.date_moved_in = residents.date_moved_in | residents_services.service_id = services.service_id | things.organization_id = organizations.organization_id | customer_events.resident_id = residents.resident_id | customer_events.property_id = residents.property_id | customer_events.date_moved_in = residents.date_moved_in | customer_events.customer_id = customers.customer_id | customer_events.thing_id = things.thing_id | customer_event_notes.customer_event_id = customer_events.customer_event_id | timed_status_of_things.thing_id = things.thing_id | timed_locations_of_things.thing_id = things.thing_id | 

### Response:

select services.service_id , services.service_details , count ( * ) from services join residents_services on services.service_id = residents_services.service_id group by services.service_id order by count ( * ) desc limit 1
### Instruction:

Convert text to sql: List the id and type of each thing, and the details of the organization that owns it. | customers : customer_id , customer_details | properties : property_id , property_type_code , property_address , other_details | residents : resident_id , property_id , date_moved_in , date_moved_out , other_details | organizations : organization_id , parent_organization_id , organization_details | services : service_id , organization_id , service_type_code , service_details | residents_services : resident_id , service_id , date_moved_in , property_id , date_requested , date_provided , other_details | things : thing_id , organization_id , type_of_thing_code , service_type_code , service_details | customer_events : customer_event_id , customer_id , date_moved_in , property_id , resident_id , thing_id | customer_event_notes : customer_event_note_id , customer_event_id , service_type_code , resident_id , property_id , date_moved_in | timed_status_of_things : thing_id , date_and_date , status_of_thing_code | timed_locations_of_things : thing_id , date_and_time , location_code | residents.property_id = properties.property_id | services.organization_id = organizations.organization_id | residents_services.resident_id = residents.resident_id | residents_services.property_id = residents.property_id | residents_services.date_moved_in = residents.date_moved_in | residents_services.service_id = services.service_id | things.organization_id = organizations.organization_id | customer_events.resident_id = residents.resident_id | customer_events.property_id = residents.property_id | customer_events.date_moved_in = residents.date_moved_in | customer_events.customer_id = customers.customer_id | customer_events.thing_id = things.thing_id | customer_event_notes.customer_event_id = customer_events.customer_event_id | timed_status_of_things.thing_id = things.thing_id | timed_locations_of_things.thing_id = things.thing_id | 

### Response:

select things.thing_id , things.type_of_thing_code , organizations.organization_details from things join organizations on things.organization_id = organizations.organization_id
### Instruction:

Convert text to sql: What are the id and details of the customers who have at least 3 events? | customers : customer_id , customer_details | properties : property_id , property_type_code , property_address , other_details | residents : resident_id , property_id , date_moved_in , date_moved_out , other_details | organizations : organization_id , parent_organization_id , organization_details | services : service_id , organization_id , service_type_code , service_details | residents_services : resident_id , service_id , date_moved_in , property_id , date_requested , date_provided , other_details | things : thing_id , organization_id , type_of_thing_code , service_type_code , service_details | customer_events : customer_event_id , customer_id , date_moved_in , property_id , resident_id , thing_id | customer_event_notes : customer_event_note_id , customer_event_id , service_type_code , resident_id , property_id , date_moved_in | timed_status_of_things : thing_id , date_and_date , status_of_thing_code | timed_locations_of_things : thing_id , date_and_time , location_code | residents.property_id = properties.property_id | services.organization_id = organizations.organization_id | residents_services.resident_id = residents.resident_id | residents_services.property_id = residents.property_id | residents_services.date_moved_in = residents.date_moved_in | residents_services.service_id = services.service_id | things.organization_id = organizations.organization_id | customer_events.resident_id = residents.resident_id | customer_events.property_id = residents.property_id | customer_events.date_moved_in = residents.date_moved_in | customer_events.customer_id = customers.customer_id | customer_events.thing_id = things.thing_id | customer_event_notes.customer_event_id = customer_events.customer_event_id | timed_status_of_things.thing_id = things.thing_id | timed_locations_of_things.thing_id = things.thing_id | 

### Response:

select customers.customer_id , customers.customer_details from customers join customer_events on customers.customer_id = customer_events.customer_id group by customers.customer_id having count ( * ) >= 3
### Instruction:

Convert text to sql: What is each customer's move in date, and the corresponding customer id and details? | customers : customer_id , customer_details | properties : property_id , property_type_code , property_address , other_details | residents : resident_id , property_id , date_moved_in , date_moved_out , other_details | organizations : organization_id , parent_organization_id , organization_details | services : service_id , organization_id , service_type_code , service_details | residents_services : resident_id , service_id , date_moved_in , property_id , date_requested , date_provided , other_details | things : thing_id , organization_id , type_of_thing_code , service_type_code , service_details | customer_events : customer_event_id , customer_id , date_moved_in , property_id , resident_id , thing_id | customer_event_notes : customer_event_note_id , customer_event_id , service_type_code , resident_id , property_id , date_moved_in | timed_status_of_things : thing_id , date_and_date , status_of_thing_code | timed_locations_of_things : thing_id , date_and_time , location_code | residents.property_id = properties.property_id | services.organization_id = organizations.organization_id | residents_services.resident_id = residents.resident_id | residents_services.property_id = residents.property_id | residents_services.date_moved_in = residents.date_moved_in | residents_services.service_id = services.service_id | things.organization_id = organizations.organization_id | customer_events.resident_id = residents.resident_id | customer_events.property_id = residents.property_id | customer_events.date_moved_in = residents.date_moved_in | customer_events.customer_id = customers.customer_id | customer_events.thing_id = things.thing_id | customer_event_notes.customer_event_id = customer_events.customer_event_id | timed_status_of_things.thing_id = things.thing_id | timed_locations_of_things.thing_id = things.thing_id | 

### Response:

select customer_events.date_moved_in , customers.customer_id , customers.customer_details from customers join customer_events on customers.customer_id = customer_events.customer_id
### Instruction:

Convert text to sql: Which events have the number of notes between one and three? List the event id and the property id. | customers : customer_id , customer_details | properties : property_id , property_type_code , property_address , other_details | residents : resident_id , property_id , date_moved_in , date_moved_out , other_details | organizations : organization_id , parent_organization_id , organization_details | services : service_id , organization_id , service_type_code , service_details | residents_services : resident_id , service_id , date_moved_in , property_id , date_requested , date_provided , other_details | things : thing_id , organization_id , type_of_thing_code , service_type_code , service_details | customer_events : customer_event_id , customer_id , date_moved_in , property_id , resident_id , thing_id | customer_event_notes : customer_event_note_id , customer_event_id , service_type_code , resident_id , property_id , date_moved_in | timed_status_of_things : thing_id , date_and_date , status_of_thing_code | timed_locations_of_things : thing_id , date_and_time , location_code | residents.property_id = properties.property_id | services.organization_id = organizations.organization_id | residents_services.resident_id = residents.resident_id | residents_services.property_id = residents.property_id | residents_services.date_moved_in = residents.date_moved_in | residents_services.service_id = services.service_id | things.organization_id = organizations.organization_id | customer_events.resident_id = residents.resident_id | customer_events.property_id = residents.property_id | customer_events.date_moved_in = residents.date_moved_in | customer_events.customer_id = customers.customer_id | customer_events.thing_id = things.thing_id | customer_event_notes.customer_event_id = customer_events.customer_event_id | timed_status_of_things.thing_id = things.thing_id | timed_locations_of_things.thing_id = things.thing_id | 

### Response:

select customer_events.customer_event_id , customer_events.property_id from customer_events join customer_event_notes on customer_events.customer_event_id = customer_event_notes.customer_event_id group by customer_events.customer_event_id having count ( * ) between 1 and 3
### Instruction:

Convert text to sql: What are the distinct id and type of the thing that has the status 'Close' or has a status record before the date '2017-06-19 02:59:21' | customers : customer_id , customer_details | properties : property_id , property_type_code , property_address , other_details | residents : resident_id , property_id , date_moved_in , date_moved_out , other_details | organizations : organization_id , parent_organization_id , organization_details | services : service_id , organization_id , service_type_code , service_details | residents_services : resident_id , service_id , date_moved_in , property_id , date_requested , date_provided , other_details | things : thing_id , organization_id , type_of_thing_code , service_type_code , service_details | customer_events : customer_event_id , customer_id , date_moved_in , property_id , resident_id , thing_id | customer_event_notes : customer_event_note_id , customer_event_id , service_type_code , resident_id , property_id , date_moved_in | timed_status_of_things : thing_id , date_and_date , status_of_thing_code | timed_locations_of_things : thing_id , date_and_time , location_code | residents.property_id = properties.property_id | services.organization_id = organizations.organization_id | residents_services.resident_id = residents.resident_id | residents_services.property_id = residents.property_id | residents_services.date_moved_in = residents.date_moved_in | residents_services.service_id = services.service_id | things.organization_id = organizations.organization_id | customer_events.resident_id = residents.resident_id | customer_events.property_id = residents.property_id | customer_events.date_moved_in = residents.date_moved_in | customer_events.customer_id = customers.customer_id | customer_events.thing_id = things.thing_id | customer_event_notes.customer_event_id = customer_events.customer_event_id | timed_status_of_things.thing_id = things.thing_id | timed_locations_of_things.thing_id = things.thing_id | 

### Response:

select distinct things.thing_id , things.type_of_thing_code from timed_status_of_things join things on timed_status_of_things.thing_id = things.thing_id where timed_status_of_things.status_of_thing_code = 'Close' or timed_status_of_things.date_and_date < '2017-06-19 02:59:21'
### Instruction:

Convert text to sql: How many distinct locations have the things with service detail 'Unsatisfied' been located in? | customers : customer_id , customer_details | properties : property_id , property_type_code , property_address , other_details | residents : resident_id , property_id , date_moved_in , date_moved_out , other_details | organizations : organization_id , parent_organization_id , organization_details | services : service_id , organization_id , service_type_code , service_details | residents_services : resident_id , service_id , date_moved_in , property_id , date_requested , date_provided , other_details | things : thing_id , organization_id , type_of_thing_code , service_type_code , service_details | customer_events : customer_event_id , customer_id , date_moved_in , property_id , resident_id , thing_id | customer_event_notes : customer_event_note_id , customer_event_id , service_type_code , resident_id , property_id , date_moved_in | timed_status_of_things : thing_id , date_and_date , status_of_thing_code | timed_locations_of_things : thing_id , date_and_time , location_code | residents.property_id = properties.property_id | services.organization_id = organizations.organization_id | residents_services.resident_id = residents.resident_id | residents_services.property_id = residents.property_id | residents_services.date_moved_in = residents.date_moved_in | residents_services.service_id = services.service_id | things.organization_id = organizations.organization_id | customer_events.resident_id = residents.resident_id | customer_events.property_id = residents.property_id | customer_events.date_moved_in = residents.date_moved_in | customer_events.customer_id = customers.customer_id | customer_events.thing_id = things.thing_id | customer_event_notes.customer_event_id = customer_events.customer_event_id | timed_status_of_things.thing_id = things.thing_id | timed_locations_of_things.thing_id = things.thing_id | 

### Response:

select count ( distinct timed_locations_of_things.location_code ) from things join timed_locations_of_things on things.thing_id = timed_locations_of_things.thing_id where things.service_details = 'Unsatisfied'
### Instruction:

Convert text to sql: How many different status codes of things are there? | customers : customer_id , customer_details | properties : property_id , property_type_code , property_address , other_details | residents : resident_id , property_id , date_moved_in , date_moved_out , other_details | organizations : organization_id , parent_organization_id , organization_details | services : service_id , organization_id , service_type_code , service_details | residents_services : resident_id , service_id , date_moved_in , property_id , date_requested , date_provided , other_details | things : thing_id , organization_id , type_of_thing_code , service_type_code , service_details | customer_events : customer_event_id , customer_id , date_moved_in , property_id , resident_id , thing_id | customer_event_notes : customer_event_note_id , customer_event_id , service_type_code , resident_id , property_id , date_moved_in | timed_status_of_things : thing_id , date_and_date , status_of_thing_code | timed_locations_of_things : thing_id , date_and_time , location_code | residents.property_id = properties.property_id | services.organization_id = organizations.organization_id | residents_services.resident_id = residents.resident_id | residents_services.property_id = residents.property_id | residents_services.date_moved_in = residents.date_moved_in | residents_services.service_id = services.service_id | things.organization_id = organizations.organization_id | customer_events.resident_id = residents.resident_id | customer_events.property_id = residents.property_id | customer_events.date_moved_in = residents.date_moved_in | customer_events.customer_id = customers.customer_id | customer_events.thing_id = things.thing_id | customer_event_notes.customer_event_id = customer_events.customer_event_id | timed_status_of_things.thing_id = things.thing_id | timed_locations_of_things.thing_id = things.thing_id | 

### Response:

select count ( distinct status_of_thing_code ) from timed_status_of_things
### Instruction:

Convert text to sql: Which organizations are not a parent organization of others? List the organization id. | customers : customer_id , customer_details | properties : property_id , property_type_code , property_address , other_details | residents : resident_id , property_id , date_moved_in , date_moved_out , other_details | organizations : organization_id , parent_organization_id , organization_details | services : service_id , organization_id , service_type_code , service_details | residents_services : resident_id , service_id , date_moved_in , property_id , date_requested , date_provided , other_details | things : thing_id , organization_id , type_of_thing_code , service_type_code , service_details | customer_events : customer_event_id , customer_id , date_moved_in , property_id , resident_id , thing_id | customer_event_notes : customer_event_note_id , customer_event_id , service_type_code , resident_id , property_id , date_moved_in | timed_status_of_things : thing_id , date_and_date , status_of_thing_code | timed_locations_of_things : thing_id , date_and_time , location_code | residents.property_id = properties.property_id | services.organization_id = organizations.organization_id | residents_services.resident_id = residents.resident_id | residents_services.property_id = residents.property_id | residents_services.date_moved_in = residents.date_moved_in | residents_services.service_id = services.service_id | things.organization_id = organizations.organization_id | customer_events.resident_id = residents.resident_id | customer_events.property_id = residents.property_id | customer_events.date_moved_in = residents.date_moved_in | customer_events.customer_id = customers.customer_id | customer_events.thing_id = things.thing_id | customer_event_notes.customer_event_id = customer_events.customer_event_id | timed_status_of_things.thing_id = things.thing_id | timed_locations_of_things.thing_id = things.thing_id | 

### Response:

select organization_id from organizations except select parent_organization_id from organizations
### Instruction:

Convert text to sql: When is the last day any resident moved in? | customers : customer_id , customer_details | properties : property_id , property_type_code , property_address , other_details | residents : resident_id , property_id , date_moved_in , date_moved_out , other_details | organizations : organization_id , parent_organization_id , organization_details | services : service_id , organization_id , service_type_code , service_details | residents_services : resident_id , service_id , date_moved_in , property_id , date_requested , date_provided , other_details | things : thing_id , organization_id , type_of_thing_code , service_type_code , service_details | customer_events : customer_event_id , customer_id , date_moved_in , property_id , resident_id , thing_id | customer_event_notes : customer_event_note_id , customer_event_id , service_type_code , resident_id , property_id , date_moved_in | timed_status_of_things : thing_id , date_and_date , status_of_thing_code | timed_locations_of_things : thing_id , date_and_time , location_code | residents.property_id = properties.property_id | services.organization_id = organizations.organization_id | residents_services.resident_id = residents.resident_id | residents_services.property_id = residents.property_id | residents_services.date_moved_in = residents.date_moved_in | residents_services.service_id = services.service_id | things.organization_id = organizations.organization_id | customer_events.resident_id = residents.resident_id | customer_events.property_id = residents.property_id | customer_events.date_moved_in = residents.date_moved_in | customer_events.customer_id = customers.customer_id | customer_events.thing_id = things.thing_id | customer_event_notes.customer_event_id = customer_events.customer_event_id | timed_status_of_things.thing_id = things.thing_id | timed_locations_of_things.thing_id = things.thing_id | 

### Response:

select max ( date_moved_in ) from residents