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

Convert text to sql: How many students who are female are allergic to milk or eggs? | allergy_type : allergy , allergytype | has_allergy : stuid , allergy | student : stuid , lname , fname , age , sex , major , advisor , city_code | has_allergy.allergy = allergy_type.allergy | has_allergy.stuid = student.stuid | 

### Response:

select count ( * ) from has_allergy join student on has_allergy.stuid = student.stuid where student.sex = 'F' and has_allergy.allergy = 'Milk' or has_allergy.allergy = 'Eggs'

### Instruction:

Convert text to sql: How many students have a food allergy? | allergy_type : allergy , allergytype | has_allergy : stuid , allergy | student : stuid , lname , fname , age , sex , major , advisor , city_code | has_allergy.allergy = allergy_type.allergy | has_allergy.stuid = student.stuid | 

### Response:

select count ( * ) from has_allergy join allergy_type on has_allergy.allergy = allergy_type.allergy where allergy_type.allergytype = 'food'

### Instruction:

Convert text to sql: How many students are affected by food related allergies? | allergy_type : allergy , allergytype | has_allergy : stuid , allergy | student : stuid , lname , fname , age , sex , major , advisor , city_code | has_allergy.allergy = allergy_type.allergy | has_allergy.stuid = student.stuid | 

### Response:

select count ( * ) from has_allergy join allergy_type on has_allergy.allergy = allergy_type.allergy where allergy_type.allergytype = 'food'

### Instruction:

Convert text to sql: Which allergy has most number of students affected? | allergy_type : allergy , allergytype | has_allergy : stuid , allergy | student : stuid , lname , fname , age , sex , major , advisor , city_code | has_allergy.allergy = allergy_type.allergy | has_allergy.stuid = student.stuid | 

### Response:

select allergy from has_allergy group by allergy order by count ( * ) desc limit 1

### Instruction:

Convert text to sql: Which allergy is the most common? | allergy_type : allergy , allergytype | has_allergy : stuid , allergy | student : stuid , lname , fname , age , sex , major , advisor , city_code | has_allergy.allergy = allergy_type.allergy | has_allergy.stuid = student.stuid | 

### Response:

select allergy from has_allergy group by allergy order by count ( * ) desc limit 1

### Instruction:

Convert text to sql: Show all allergies with number of students affected. | allergy_type : allergy , allergytype | has_allergy : stuid , allergy | student : stuid , lname , fname , age , sex , major , advisor , city_code | has_allergy.allergy = allergy_type.allergy | has_allergy.stuid = student.stuid | 

### Response:

select allergy , count ( * ) from has_allergy group by allergy

### Instruction:

Convert text to sql: How many students have each different allergy? | allergy_type : allergy , allergytype | has_allergy : stuid , allergy | student : stuid , lname , fname , age , sex , major , advisor , city_code | has_allergy.allergy = allergy_type.allergy | has_allergy.stuid = student.stuid | 

### Response:

select allergy , count ( * ) from has_allergy group by allergy
### Instruction:

Convert text to sql: Show all allergy type with number of students affected. | allergy_type : allergy , allergytype | has_allergy : stuid , allergy | student : stuid , lname , fname , age , sex , major , advisor , city_code | has_allergy.allergy = allergy_type.allergy | has_allergy.stuid = student.stuid | 

### Response:

select allergy_type.allergytype , count ( * ) from has_allergy join allergy_type on has_allergy.allergy = allergy_type.allergy group by allergy_type.allergytype

### Instruction:

Convert text to sql: How many students are affected by each allergy type? | allergy_type : allergy , allergytype | has_allergy : stuid , allergy | student : stuid , lname , fname , age , sex , major , advisor , city_code | has_allergy.allergy = allergy_type.allergy | has_allergy.stuid = student.stuid | 

### Response:

select allergy_type.allergytype , count ( * ) from has_allergy join allergy_type on has_allergy.allergy = allergy_type.allergy group by allergy_type.allergytype

### Instruction:

Convert text to sql: Find the last name and age of the student who has allergy to both milk and cat. | allergy_type : allergy , allergytype | has_allergy : stuid , allergy | student : stuid , lname , fname , age , sex , major , advisor , city_code | has_allergy.allergy = allergy_type.allergy | has_allergy.stuid = student.stuid | 

### Response:

select lname , age from student where stuid in ( select stuid from has_allergy where allergy = 'Milk' intersect select stuid from has_allergy where allergy = 'Cat' )

### Instruction:

Convert text to sql: What are the last names and ages of the students who are allergic to milk and cat? | allergy_type : allergy , allergytype | has_allergy : stuid , allergy | student : stuid , lname , fname , age , sex , major , advisor , city_code | has_allergy.allergy = allergy_type.allergy | has_allergy.stuid = student.stuid | 

### Response:

select lname , age from student where stuid in ( select stuid from has_allergy where allergy = 'Milk' intersect select stuid from has_allergy where allergy = 'Cat' )

### Instruction:

Convert text to sql: What are the allergies and their types that the student with first name Lisa has? And order the result by name of allergies. | allergy_type : allergy , allergytype | has_allergy : stuid , allergy | student : stuid , lname , fname , age , sex , major , advisor , city_code | has_allergy.allergy = allergy_type.allergy | has_allergy.stuid = student.stuid | 

### Response:

select allergy_type.allergy , allergy_type.allergytype from allergy_type join has_allergy on allergy_type.allergy = has_allergy.allergy join student on student.stuid = has_allergy.stuid where student.fname = 'Lisa' order by allergy_type.allergy asc
### Instruction:

Convert text to sql: What are the allergies the girl named Lisa has? And what are the types of them? Order the result by allergy names. | allergy_type : allergy , allergytype | has_allergy : stuid , allergy | student : stuid , lname , fname , age , sex , major , advisor , city_code | has_allergy.allergy = allergy_type.allergy | has_allergy.stuid = student.stuid | 

### Response:

select allergy_type.allergy , allergy_type.allergytype from allergy_type join has_allergy on allergy_type.allergy = has_allergy.allergy join student on student.stuid = has_allergy.stuid where student.fname = 'Lisa' order by allergy_type.allergy asc

### Instruction:

Convert text to sql: Find the first name and gender of the student who has allergy to milk but not cat. | allergy_type : allergy , allergytype | has_allergy : stuid , allergy | student : stuid , lname , fname , age , sex , major , advisor , city_code | has_allergy.allergy = allergy_type.allergy | has_allergy.stuid = student.stuid | 

### Response:

select fname , sex from student where stuid in ( select stuid from has_allergy where allergy = 'Milk' except select stuid from has_allergy where allergy = 'Cat' )

### Instruction:

Convert text to sql: What are the first name and gender of the students who have allergy to milk but can put up with cats? | allergy_type : allergy , allergytype | has_allergy : stuid , allergy | student : stuid , lname , fname , age , sex , major , advisor , city_code | has_allergy.allergy = allergy_type.allergy | has_allergy.stuid = student.stuid | 

### Response:

select fname , sex from student where stuid in ( select stuid from has_allergy where allergy = 'Milk' except select stuid from has_allergy where allergy = 'Cat' )

### Instruction:

Convert text to sql: Find the average age of the students who have allergies with food and animal types. | allergy_type : allergy , allergytype | has_allergy : stuid , allergy | student : stuid , lname , fname , age , sex , major , advisor , city_code | has_allergy.allergy = allergy_type.allergy | has_allergy.stuid = student.stuid | 

### Response:

select avg ( age ) from student where stuid in ( select has_allergy.stuid from has_allergy join allergy_type on has_allergy.allergy = allergy_type.allergy where allergy_type.allergytype = 'food' intersect select has_allergy.stuid from has_allergy join allergy_type on has_allergy.allergy = allergy_type.allergy where allergy_type.allergytype = 'animal' )

### Instruction:

Convert text to sql: How old are the students with allergies to food and animal types on average? | allergy_type : allergy , allergytype | has_allergy : stuid , allergy | student : stuid , lname , fname , age , sex , major , advisor , city_code | has_allergy.allergy = allergy_type.allergy | has_allergy.stuid = student.stuid | 

### Response:

select avg ( age ) from student where stuid in ( select has_allergy.stuid from has_allergy join allergy_type on has_allergy.allergy = allergy_type.allergy where allergy_type.allergytype = 'food' intersect select has_allergy.stuid from has_allergy join allergy_type on has_allergy.allergy = allergy_type.allergy where allergy_type.allergytype = 'animal' )
### Instruction:

Convert text to sql: List the first and last name of the students who do not have any food type allergy. | allergy_type : allergy , allergytype | has_allergy : stuid , allergy | student : stuid , lname , fname , age , sex , major , advisor , city_code | has_allergy.allergy = allergy_type.allergy | has_allergy.stuid = student.stuid | 

### Response:

select fname , lname from student where stuid not in ( select has_allergy.stuid from has_allergy join allergy_type on has_allergy.allergy = allergy_type.allergy where allergy_type.allergytype = 'food' )

### Instruction:

Convert text to sql: What is the full name of each student who is not allergic to any type of food. | allergy_type : allergy , allergytype | has_allergy : stuid , allergy | student : stuid , lname , fname , age , sex , major , advisor , city_code | has_allergy.allergy = allergy_type.allergy | has_allergy.stuid = student.stuid | 

### Response:

select fname , lname from student where stuid not in ( select has_allergy.stuid from has_allergy join allergy_type on has_allergy.allergy = allergy_type.allergy where allergy_type.allergytype = 'food' )

### Instruction:

Convert text to sql: Find the number of male (sex is 'M') students who have some food type allery. | allergy_type : allergy , allergytype | has_allergy : stuid , allergy | student : stuid , lname , fname , age , sex , major , advisor , city_code | has_allergy.allergy = allergy_type.allergy | has_allergy.stuid = student.stuid | 

### Response:

select count ( * ) from student where sex = 'M' and stuid in ( select stuid from has_allergy join allergy_type on has_allergy.allergy = allergy_type.allergy where allergy_type.allergytype = 'food' )

### Instruction:

Convert text to sql: How many male students (sex is 'M') are allergic to any type of food? | allergy_type : allergy , allergytype | has_allergy : stuid , allergy | student : stuid , lname , fname , age , sex , major , advisor , city_code | has_allergy.allergy = allergy_type.allergy | has_allergy.stuid = student.stuid | 

### Response:

select count ( * ) from student where sex = 'M' and stuid in ( select stuid from has_allergy join allergy_type on has_allergy.allergy = allergy_type.allergy where allergy_type.allergytype = 'food' )

### Instruction:

Convert text to sql: Find the different first names and cities of the students who have allergy to milk or cat. | allergy_type : allergy , allergytype | has_allergy : stuid , allergy | student : stuid , lname , fname , age , sex , major , advisor , city_code | has_allergy.allergy = allergy_type.allergy | has_allergy.stuid = student.stuid | 

### Response:

select distinct student.fname , student.city_code from student join has_allergy on student.stuid = has_allergy.stuid where has_allergy.allergy = 'Milk' or has_allergy.allergy = 'Cat'
### Instruction:

Convert text to sql: What are the distinct first names and cities of the students who have allergy either to milk or to cat? | allergy_type : allergy , allergytype | has_allergy : stuid , allergy | student : stuid , lname , fname , age , sex , major , advisor , city_code | has_allergy.allergy = allergy_type.allergy | has_allergy.stuid = student.stuid | 

### Response:

select distinct student.fname , student.city_code from student join has_allergy on student.stuid = has_allergy.stuid where has_allergy.allergy = 'Milk' or has_allergy.allergy = 'Cat'

### Instruction:

Convert text to sql: Find the number of students who are older than 18 and do not have allergy to either food or animal. | allergy_type : allergy , allergytype | has_allergy : stuid , allergy | student : stuid , lname , fname , age , sex , major , advisor , city_code | has_allergy.allergy = allergy_type.allergy | has_allergy.stuid = student.stuid | 

### Response:

select count ( * ) from student where age > 18 and stuid not in ( select stuid from has_allergy join allergy_type on has_allergy.allergy = allergy_type.allergy where allergy_type.allergytype = 'food' or allergy_type.allergytype = 'animal' )

### Instruction:

Convert text to sql: How many students are over 18 and do not have allergy to food type or animal type? | allergy_type : allergy , allergytype | has_allergy : stuid , allergy | student : stuid , lname , fname , age , sex , major , advisor , city_code | has_allergy.allergy = allergy_type.allergy | has_allergy.stuid = student.stuid | 

### Response:

select count ( * ) from student where age > 18 and stuid not in ( select stuid from has_allergy join allergy_type on has_allergy.allergy = allergy_type.allergy where allergy_type.allergytype = 'food' or allergy_type.allergytype = 'animal' )

### Instruction:

Convert text to sql: Find the first name and major of the students who are not allegry to soy. | allergy_type : allergy , allergytype | has_allergy : stuid , allergy | student : stuid , lname , fname , age , sex , major , advisor , city_code | has_allergy.allergy = allergy_type.allergy | has_allergy.stuid = student.stuid | 

### Response:

select fname , major from student where stuid not in ( select stuid from has_allergy where allergy = 'Soy' )

### Instruction:

Convert text to sql: What are the first name and major of the students who are able to consume soy? | allergy_type : allergy , allergytype | has_allergy : stuid , allergy | student : stuid , lname , fname , age , sex , major , advisor , city_code | has_allergy.allergy = allergy_type.allergy | has_allergy.stuid = student.stuid | 

### Response:

select fname , major from student where stuid not in ( select stuid from has_allergy where allergy = 'Soy' )
### Instruction:

Convert text to sql: A list of the top 5 countries by number of invoices. List country name and number of invoices. | artists : id , name | sqlite_sequence : name , seq | albums : id , title , artist_id | employees : id , last_name , first_name , title , reports_to , birth_date , hire_date , address , city , state , country , postal_code , phone , fax , email | customers : id , first_name , last_name , company , address , city , state , country , postal_code , phone , fax , email , support_rep_id | genres : id , name | invoices : id , customer_id , invoice_date , billing_address , billing_city , billing_state , billing_country , billing_postal_code , total | media_types : id , name | tracks : id , name , album_id , media_type_id , genre_id , composer , milliseconds , bytes , unit_price | invoice_lines : id , invoice_id , track_id , unit_price , quantity | playlists : id , name | playlist_tracks : playlist_id , track_id | albums.artist_id = artists.id | employees.reports_to = employees.id | customers.support_rep_id = employees.id | invoices.customer_id = customers.id | tracks.media_type_id = media_types.id | tracks.genre_id = genres.id | tracks.album_id = albums.id | invoice_lines.track_id = tracks.id | invoice_lines.invoice_id = invoices.id | playlist_tracks.track_id = tracks.id | playlist_tracks.playlist_id = playlists.id | 

### Response:

select billing_country , count ( * ) from invoices group by billing_country order by count ( * ) desc limit 5

### Instruction:

Convert text to sql: What are the top 5 countries by number of invoices and how many do they have? | artists : id , name | sqlite_sequence : name , seq | albums : id , title , artist_id | employees : id , last_name , first_name , title , reports_to , birth_date , hire_date , address , city , state , country , postal_code , phone , fax , email | customers : id , first_name , last_name , company , address , city , state , country , postal_code , phone , fax , email , support_rep_id | genres : id , name | invoices : id , customer_id , invoice_date , billing_address , billing_city , billing_state , billing_country , billing_postal_code , total | media_types : id , name | tracks : id , name , album_id , media_type_id , genre_id , composer , milliseconds , bytes , unit_price | invoice_lines : id , invoice_id , track_id , unit_price , quantity | playlists : id , name | playlist_tracks : playlist_id , track_id | albums.artist_id = artists.id | employees.reports_to = employees.id | customers.support_rep_id = employees.id | invoices.customer_id = customers.id | tracks.media_type_id = media_types.id | tracks.genre_id = genres.id | tracks.album_id = albums.id | invoice_lines.track_id = tracks.id | invoice_lines.invoice_id = invoices.id | playlist_tracks.track_id = tracks.id | playlist_tracks.playlist_id = playlists.id | 

### Response:

select billing_country , count ( * ) from invoices group by billing_country order by count ( * ) desc limit 5
### Instruction:

Convert text to sql: A list of the top 8 countries by gross/total invoice size. List country name and gross invoice size. | artists : id , name | sqlite_sequence : name , seq | albums : id , title , artist_id | employees : id , last_name , first_name , title , reports_to , birth_date , hire_date , address , city , state , country , postal_code , phone , fax , email | customers : id , first_name , last_name , company , address , city , state , country , postal_code , phone , fax , email , support_rep_id | genres : id , name | invoices : id , customer_id , invoice_date , billing_address , billing_city , billing_state , billing_country , billing_postal_code , total | media_types : id , name | tracks : id , name , album_id , media_type_id , genre_id , composer , milliseconds , bytes , unit_price | invoice_lines : id , invoice_id , track_id , unit_price , quantity | playlists : id , name | playlist_tracks : playlist_id , track_id | albums.artist_id = artists.id | employees.reports_to = employees.id | customers.support_rep_id = employees.id | invoices.customer_id = customers.id | tracks.media_type_id = media_types.id | tracks.genre_id = genres.id | tracks.album_id = albums.id | invoice_lines.track_id = tracks.id | invoice_lines.invoice_id = invoices.id | playlist_tracks.track_id = tracks.id | playlist_tracks.playlist_id = playlists.id | 

### Response:

select billing_country , sum ( total ) from invoices group by billing_country order by sum ( total ) desc limit 8

### Instruction:

Convert text to sql: What are the names of the top 8 countries by total invoice size and what are those sizes? | artists : id , name | sqlite_sequence : name , seq | albums : id , title , artist_id | employees : id , last_name , first_name , title , reports_to , birth_date , hire_date , address , city , state , country , postal_code , phone , fax , email | customers : id , first_name , last_name , company , address , city , state , country , postal_code , phone , fax , email , support_rep_id | genres : id , name | invoices : id , customer_id , invoice_date , billing_address , billing_city , billing_state , billing_country , billing_postal_code , total | media_types : id , name | tracks : id , name , album_id , media_type_id , genre_id , composer , milliseconds , bytes , unit_price | invoice_lines : id , invoice_id , track_id , unit_price , quantity | playlists : id , name | playlist_tracks : playlist_id , track_id | albums.artist_id = artists.id | employees.reports_to = employees.id | customers.support_rep_id = employees.id | invoices.customer_id = customers.id | tracks.media_type_id = media_types.id | tracks.genre_id = genres.id | tracks.album_id = albums.id | invoice_lines.track_id = tracks.id | invoice_lines.invoice_id = invoices.id | playlist_tracks.track_id = tracks.id | playlist_tracks.playlist_id = playlists.id | 

### Response:

select billing_country , sum ( total ) from invoices group by billing_country order by sum ( total ) desc limit 8
### Instruction:

Convert text to sql: A list of the top 10 countries by average invoice size. List country name and average invoice size. | artists : id , name | sqlite_sequence : name , seq | albums : id , title , artist_id | employees : id , last_name , first_name , title , reports_to , birth_date , hire_date , address , city , state , country , postal_code , phone , fax , email | customers : id , first_name , last_name , company , address , city , state , country , postal_code , phone , fax , email , support_rep_id | genres : id , name | invoices : id , customer_id , invoice_date , billing_address , billing_city , billing_state , billing_country , billing_postal_code , total | media_types : id , name | tracks : id , name , album_id , media_type_id , genre_id , composer , milliseconds , bytes , unit_price | invoice_lines : id , invoice_id , track_id , unit_price , quantity | playlists : id , name | playlist_tracks : playlist_id , track_id | albums.artist_id = artists.id | employees.reports_to = employees.id | customers.support_rep_id = employees.id | invoices.customer_id = customers.id | tracks.media_type_id = media_types.id | tracks.genre_id = genres.id | tracks.album_id = albums.id | invoice_lines.track_id = tracks.id | invoice_lines.invoice_id = invoices.id | playlist_tracks.track_id = tracks.id | playlist_tracks.playlist_id = playlists.id | 

### Response:

select billing_country , avg ( total ) from invoices group by billing_country order by avg ( total ) desc limit 10

### Instruction:

Convert text to sql: What are the names of the countries and average invoice size of the top countries by size? | artists : id , name | sqlite_sequence : name , seq | albums : id , title , artist_id | employees : id , last_name , first_name , title , reports_to , birth_date , hire_date , address , city , state , country , postal_code , phone , fax , email | customers : id , first_name , last_name , company , address , city , state , country , postal_code , phone , fax , email , support_rep_id | genres : id , name | invoices : id , customer_id , invoice_date , billing_address , billing_city , billing_state , billing_country , billing_postal_code , total | media_types : id , name | tracks : id , name , album_id , media_type_id , genre_id , composer , milliseconds , bytes , unit_price | invoice_lines : id , invoice_id , track_id , unit_price , quantity | playlists : id , name | playlist_tracks : playlist_id , track_id | albums.artist_id = artists.id | employees.reports_to = employees.id | customers.support_rep_id = employees.id | invoices.customer_id = customers.id | tracks.media_type_id = media_types.id | tracks.genre_id = genres.id | tracks.album_id = albums.id | invoice_lines.track_id = tracks.id | invoice_lines.invoice_id = invoices.id | playlist_tracks.track_id = tracks.id | playlist_tracks.playlist_id = playlists.id | 

### Response:

select billing_country , avg ( total ) from invoices group by billing_country order by avg ( total ) desc limit 10