ajayk007/querysmith-spider-bird huggingface dataset:
system: You are a text-to-SQL generator. Given a database schema and a question, reply with a single valid SQLite query that answers it. Output only the SQL on one line, with no explanation and no markdown.

user: Schema:
CREATE TABLE employee (
  employee_id integer PRIMARY KEY,
  first_name text,
  last_name text,
  address text,
  city text,
  state text,
  zip integer,
  phone text,
  title text,
  salary integer,
  supervisor integer
);
CREATE TABLE establishment (
  license_no integer PRIMARY KEY,
  dba_name text,
  aka_name text,
  facility_type text,
  risk_level integer,
  address text,
  city text,
  state text,
  zip integer,
  latitude real,
  longitude real,
  ward integer
);
CREATE TABLE inspection (
  inspection_id integer PRIMARY KEY,
  inspection_date date,
  inspection_type text,
  results text,
  employee_id integer,
  license_no integer,
  followup_to integer
);
CREATE TABLE inspection_point (
  point_id integer PRIMARY KEY,
  Description text,
  category text,
  code text,
  fine integer,
  point_level text
);
CREATE TABLE violation (
  inspection_id integer PRIMARY KEY,
  point_id integer PRIMARY KEY,
  fine integer,
  inspector_comment text
);
-- foreign keys: employee.supervisor -> employee.employee_id; inspection.followup_to -> inspection.inspection_id; inspection.license_no -> establishment.license_no; inspection.employee_id -> employee.employee_id; violation.point_id -> inspection_point.point_id; violation.inspection_id -> inspection.inspection_id

Hint: under the personnel category refers to category = 'Personnel'

Question: How many inspections were done under the personnel category?

assistant: SELECT COUNT(T1.inspection_id) FROM violation AS T1 INNER JOIN inspection_point AS T2 ON T1.point_id = T2.point_id WHERE T2.category = 'Personnel'
system: You are a text-to-SQL generator. Given a database schema and a question, reply with a single valid SQLite query that answers it. Output only the SQL on one line, with no explanation and no markdown.

user: Schema:
CREATE TABLE app_all (
  app_id integer PRIMARY KEY
);
CREATE TABLE app_events (
  event_id integer PRIMARY KEY,
  app_id integer PRIMARY KEY,
  is_installed integer,
  is_active integer
);
CREATE TABLE app_events_relevant (
  event_id integer PRIMARY KEY,
  app_id integer PRIMARY KEY,
  is_installed integer,
  is_active integer
);
CREATE TABLE app_labels (
  app_id integer,
  label_id integer
);
CREATE TABLE events (
  event_id integer PRIMARY KEY,
  device_id integer,
  timestamp datetime,
  longitude real,
  latitude real
);
CREATE TABLE events_relevant (
  event_id integer PRIMARY KEY,
  device_id integer,
  timestamp datetime,
  longitude real,
  latitude real
);
CREATE TABLE gender_age (
  device_id integer PRIMARY KEY,
  gender text,
  age integer,
  group text
);
CREATE TABLE gender_age_test (
  device_id integer PRIMARY KEY
);
CREATE TABLE gender_age_train (
  device_id integer PRIMARY KEY,
  gender text,
  age integer,
  group text
);
CREATE TABLE label_categories (
  label_id integer PRIMARY KEY,
  category text
);
CREATE TABLE phone_brand_device_model2 (
  device_id integer PRIMARY KEY,
  phone_brand text PRIMARY KEY,
  device_model text PRIMARY KEY
);
CREATE TABLE sample_submission (
  device_id integer PRIMARY KEY,
  F23- real,
  F24-26 real,
  F27-28 real,
  F29-32 real,
  F33-42 real,
  F43+ real,
  M22- real,
  M23-26 real,
  M27-28 real,
  M29-31 real,
  M32-38 real,
  M39+ real
);
-- foreign keys: app_events.event_id -> events.event_id; app_events_relevant.app_id -> app_all.app_id; app_events_relevant.event_id -> events_relevant.event_id; app_labels.app_id -> app_all.app_id; app_labels.label_id -> label_categories.label_id; events_relevant.device_id -> gender_age.device_id; gender_age.device_id -> phone_brand_device_model2.device_id

Hint: OPPO devices refers to phone_brand = 'OPPO';

Question: How many OPPO devices are there?

assistant: SELECT COUNT(device_id) FROM phone_brand_device_model2 WHERE phone_brand = 'OPPO'
system: You are a text-to-SQL generator. Given a database schema and a question, reply with a single valid SQLite query that answers it. Output only the SQL on one line, with no explanation and no markdown.

user: Schema:
PRAGMA foreign_keys = ON;

CREATE TABLE "captain" (
"Captain_ID" int,
"Name" text,
"Ship_ID" int,
"age" text,
"Class" text,
"Rank" text,
PRIMARY KEY ("Captain_ID"),
FOREIGN KEY ("Ship_ID") REFERENCES "Ship"("Ship_ID")
);

CREATE TABLE "Ship" (
"Ship_ID" int,
"Name" text,
"Type" text,
"Built_Year" real,
"Class" text,
"Flag" text,
PRIMARY KEY ("Ship_ID")
);

Question: What are the average and minimum age of captains in different class?

assistant: SELECT avg(age) , min(age) , CLASS FROM captain GROUP BY CLASS
system: You are a text-to-SQL generator. Given a database schema and a question, reply with a single valid SQLite query that answers it. Output only the SQL on one line, with no explanation and no markdown.

user: Schema:
CREATE TABLE lists (
  user_id integer,
  list_id integer PRIMARY KEY,
  list_title text,
  list_movie_number integer,
  list_update_timestamp_utc text,
  list_creation_timestamp_utc text,
  list_followers integer,
  list_url text,
  list_comments integer,
  list_description text,
  list_cover_image_url text,
  list_first_image_url text,
  list_second_image_url text,
  list_third_image_url text
);
CREATE TABLE movies (
  movie_id integer PRIMARY KEY,
  movie_title text,
  movie_release_year integer,
  movie_url text,
  movie_title_language text,
  movie_popularity integer,
  movie_image_url text,
  director_id text,
  director_name text,
  director_url text
);
CREATE TABLE ratings_users (
  user_id integer,
  rating_date_utc text,
  user_trialist integer,
  user_subscriber integer,
  user_avatar_image_url text,
  user_cover_image_url text,
  user_eligible_for_trial integer,
  user_has_payment_method integer
);
CREATE TABLE lists_users (
  user_id integer PRIMARY KEY,
  list_id integer PRIMARY KEY,
  list_update_date_utc text,
  list_creation_date_utc text,
  user_trialist integer,
  user_subscriber integer,
  user_avatar_image_url text,
  user_cover_image_url text,
  user_eligible_for_trial text,
  user_has_payment_method text
);
CREATE TABLE ratings (
  movie_id integer,
  rating_id integer,
  rating_url text,
  rating_score integer,
  rating_timestamp_utc text,
  critic text,
  critic_likes integer,
  critic_comments integer,
  user_id integer,
  user_trialist integer,
  user_subscriber integer,
  user_eligible_for_trial integer,
  user_has_payment_method integer
);
-- foreign keys: lists.user_id -> lists_users.user_id; ratings_users.user_id -> lists_users.user_id; lists_users.user_id -> lists.user_id; lists_users.list_id -> lists.list_id; ratings.user_id -> ratings_users.user_id; ratings.user_id -> lists_users.user_id; ratings.movie_id -> movies.movie_id

Hint: critic received the highest amount of likes refers to MAX(critic_likes);

Question: What is the name of the movie whose critic received the highest amount of likes? Indicate the URL to the rating on Mubi.

assistant: SELECT T2.movie_title, T1.rating_url FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id ORDER BY T1.critic_likes DESC LIMIT 1
system: You are a text-to-SQL generator. Given a database schema and a question, reply with a single valid SQLite query that answers it. Output only the SQL on one line, with no explanation and no markdown.

user: Schema:
PRAGMA foreign_keys = ON;


CREATE TABLE "program" (
"Program_ID" int,
"Name" text,
"Origin" text,
"Launch" real,
"Owner" text,
PRIMARY KEY ("Program_ID")
);


CREATE TABLE "channel" (
"Channel_ID" int,
"Name" text,
"Owner" text,
"Share_in_percent" real,
"Rating_in_percent" real,
PRIMARY KEY ("Channel_ID")
);

Question: Find the name of the program that is broadcast most frequently.

assistant: SELECT t1.name FROM program AS t1 JOIN broadcast AS t2 ON t1.program_id = t2.program_id GROUP BY t2.program_id ORDER BY count(*) DESC LIMIT 1
system: You are a text-to-SQL generator. Given a database schema and a question, reply with a single valid SQLite query that answers it. Output only the SQL on one line, with no explanation and no markdown.

user: Schema:
PRAGMA foreign_keys = ON;

CREATE TABLE "product" (
"product_id" int,
"product" text,
"dimensions" text,
"dpi" real,
"pages_per_minute_color" real,
"max_page_size" text,
"interface" text,
PRIMARY KEY ("product_id")
);

CREATE TABLE "store" (
"Store_ID" int,
"Store_Name" text,
"Type" text,
"Area_size" real,
"Number_of_product_category" real,
"Ranking" int,
PRIMARY KEY ("Store_ID")
);

CREATE TABLE "district" (
"District_ID" int,
"District_name" text,
"Headquartered_City" text,
"City_Population" real,
"City_Area" real,
PRIMARY KEY ("District_ID")
);

Question: What is the name of the district with the most residents?

assistant: SELECT district_name FROM district ORDER BY city_population DESC LIMIT 1
system: You are a text-to-SQL generator. Given a database schema and a question, reply with a single valid SQLite query that answers it. Output only the SQL on one line, with no explanation and no markdown.

user: Schema:
CREATE TABLE Air Carriers (
  Code integer PRIMARY KEY,
  Description text
);
CREATE TABLE Airports (
  Code text PRIMARY KEY,
  Description text
);
CREATE TABLE Airlines (
  FL_DATE text,
  OP_CARRIER_AIRLINE_ID integer,
  TAIL_NUM text,
  OP_CARRIER_FL_NUM integer,
  ORIGIN_AIRPORT_ID integer,
  ORIGIN_AIRPORT_SEQ_ID integer,
  ORIGIN_CITY_MARKET_ID integer,
  ORIGIN text,
  DEST_AIRPORT_ID integer,
  DEST_AIRPORT_SEQ_ID integer,
  DEST_CITY_MARKET_ID integer,
  DEST text,
  CRS_DEP_TIME integer,
  DEP_TIME integer,
  DEP_DELAY integer,
  DEP_DELAY_NEW integer,
  ARR_TIME integer,
  ARR_DELAY integer,
  ARR_DELAY_NEW integer,
  CANCELLED integer,
  CANCELLATION_CODE text,
  CRS_ELAPSED_TIME integer,
  ACTUAL_ELAPSED_TIME integer,
  CARRIER_DELAY integer,
  WEATHER_DELAY integer,
  NAS_DELAY integer,
  SECURITY_DELAY integer,
  LATE_AIRCRAFT_DELAY integer
);
-- foreign keys: Airlines.OP_CARRIER_AIRLINE_ID -> Air Carriers.Code; Airlines.DEST -> Airports.Code; Airlines.ORIGIN -> Airports.Code

Hint: American Airlines Inc. refers to Description = 'American Airlines Inc.: AA'; land in New York refers to DEST = 'JFK';

Question: Among the flights operated by American Airlines Inc., how many of them were scheduled to land in New York?

assistant: SELECT SUM(CASE WHEN T2.DEST = 'JFK' THEN 1 ELSE 0 END) AS count FROM Airports AS T1 INNER JOIN Airlines AS T2 ON T1.Code = T2.DEST INNER JOIN `Air Carriers` AS T3 ON T2.OP_CARRIER_AIRLINE_ID = T3.Code WHERE T3.Description = 'American Airlines Inc.: AA'
system: You are a text-to-SQL generator. Given a database schema and a question, reply with a single valid SQLite query that answers it. Output only the SQL on one line, with no explanation and no markdown.

user: Schema:
PRAGMA foreign_keys = ON;

CREATE TABLE "aircraft" (
"Aircraft_ID" int,
"Order_Year" int,
"Manufacturer" text,
"Model" text,
"Fleet_Series" text,
"Powertrain" text,
"Fuel_Propulsion" text,
PRIMARY KEY ("Aircraft_ID")
);


CREATE TABLE "pilot" (
"Pilot_ID" int,
"Pilot_name" text,
"Rank" int,
"Age" int,
"Nationality" text,
"Position" text,
"Join_Year" int,
"Team" text,
PRIMARY KEY ("Pilot_ID")
);

Question: Show the pilot positions that have both pilots joining after year 2005 and pilots joining before 2000.

assistant: SELECT POSITION FROM pilot WHERE Join_Year < 2000 INTERSECT SELECT POSITION FROM pilot WHERE Join_Year > 2005
system: You are a text-to-SQL generator. Given a database schema and a question, reply with a single valid SQLite query that answers it. Output only the SQL on one line, with no explanation and no markdown.

user: Schema:
-- dbext:type=SQLITE:dbname=movie_rating.db

/* Delete the tables if they already exist */
drop table if exists Movie;
drop table if exists Reviewer;
drop table if exists Rating;

/* Create the schema for our tables */
create table Movie(
	mID int primary key, 
	title text, 
	year int, 
	director text
);
create table Reviewer(
	rID int primary key, 
	name text);

create table Rating(
	rID int, 
	mID int, 
	stars int, 
	ratingDate date,
	FOREIGN KEY (mID) references Movie(mID),
	FOREIGN KEY (rID) references Reviewer(rID)
);

/* Populate the tables with our data */

Question: How many movie ratings have more than 3 stars?

assistant: SELECT count(*) FROM Rating WHERE stars > 3
system: You are a text-to-SQL generator. Given a database schema and a question, reply with a single valid SQLite query that answers it. Output only the SQL on one line, with no explanation and no markdown.

user: Schema:
create table Student (
        StuID        INTEGER PRIMARY KEY,
        LName        VARCHAR(12),
        Fname        VARCHAR(12),
        Age      INTEGER,
        Sex      VARCHAR(1),
        Major        INTEGER,
        Advisor      INTEGER,
        city_code    VARCHAR(3)
 );

create table Restaurant (
       ResID       INTEGER PRIMARY KEY,
       ResName     VARCHAR(100),
       Address     VARCHAR(100),
       Rating INTEGER
);

create table Type_Of_Restaurant (
       ResID       INTEGER,
       ResTypeID   INTEGER,
       FOREIGN KEY(ResID) REFERENCES Restaurant(ResID),
       FOREIGN KEY(ResTypeID) REFERENCES Restaurant_Type(ResTypeID)
);

create table Restaurant_Type (
       ResTypeID            INTEGER PRIMARY KEY,
       ResTypeName          VARCHAR(40),
       ResTypeDescription   VARCHAR(100)
);

create table Visits_Restaurant (
       StuID      INTEGER,
       ResID      INTEGER,
       Time       TIMESTAMP,
       Spent      FLOAT,
       FOREIGN KEY(StuID) REFERENCES Student(StuID),
       FOREIGN KEY(ResID) REFERENCES Restaurant(ResID)
);

Question: List all students' first names and last names who majored in 600.

assistant: SELECT Fname , Lname FROM Student WHERE Major = 600;
system: You are a text-to-SQL generator. Given a database schema and a question, reply with a single valid SQLite query that answers it. Output only the SQL on one line, with no explanation and no markdown.

user: Schema:
PRAGMA foreign_keys = ON;


CREATE TABLE "film" (
"Film_ID" int,
"Rank_in_series" int,
"Number_in_season" int,
"Title" text,
"Directed_by" text,
"Original_air_date" text,
"Production_code" text,
PRIMARY KEY ("Film_ID")
);

CREATE TABLE "cinema" (
"Cinema_ID" int,
"Name" text,
"Openning_year" int,
"Capacity" int,
"Location" text,
PRIMARY KEY ("Cinema_ID"));

Question: In which locations are there more than one movie theater with capacity above 300?

assistant: SELECT LOCATION FROM cinema WHERE capacity > 300 GROUP BY LOCATION HAVING count(*) > 1
system: You are a text-to-SQL generator. Given a database schema and a question, reply with a single valid SQLite query that answers it. Output only the SQL on one line, with no explanation and no markdown.

user: Schema:
CREATE TABLE Demog (
  GEOID integer PRIMARY KEY,
  INHABITANTS_K real,
  INCOME_K real,
  A_VAR1 real,
  A_VAR2 real,
  A_VAR3 real,
  A_VAR4 real,
  A_VAR5 real,
  A_VAR6 real,
  A_VAR7 real,
  A_VAR8 real,
  A_VAR9 real,
  A_VAR10 real,
  A_VAR11 real,
  A_VAR12 real,
  A_VAR13 real,
  A_VAR14 real,
  A_VAR15 real,
  A_VAR16 real,
  A_VAR17 real,
  A_VAR18 real
);
CREATE TABLE mailings3 (
  REFID integer PRIMARY KEY,
  REF_DATE datetime,
  RESPONSE text
);
CREATE TABLE Customers (
  ID integer PRIMARY KEY,
  SEX text,
  MARITAL_STATUS text,
  GEOID integer,
  EDUCATIONNUM integer,
  OCCUPATION text,
  age integer
);
CREATE TABLE Mailings1_2 (
  REFID integer PRIMARY KEY,
  REF_DATE datetime,
  RESPONSE text
);
CREATE TABLE Sales (
  EVENTID integer PRIMARY KEY,
  REFID integer,
  EVENT_DATE datetime,
  AMOUNT real
);

Hint: geographic identifier from 20 to 50 refers to GEOID BETWEEN 20 AND 50; number of inhabitants below 20 refers to INHABITANTS_K < 20;

Question: In geographic identifier from 20 to 50, how many of them has a number of inhabitants below 20?

assistant: SELECT COUNT(GEOID) FROM Demog WHERE INHABITANTS_K < 20 AND GEOID >= 20 AND GEOID <= 50
system: You are a text-to-SQL generator. Given a database schema and a question, reply with a single valid SQLite query that answers it. Output only the SQL on one line, with no explanation and no markdown.

user: Schema:
PRAGMA foreign_keys = ON;
CREATE TABLE Customers (
Customer_ID INTEGER NOT NULL,
Customer_Details VARCHAR(255) NOT NULL,
PRIMARY KEY (Customer_ID)
);

Question: Find the claim id and claim date of the claim that incurred the most settlement count. Also tell me the count.

assistant: SELECT T1.claim_id , T1.date_claim_made , count(*) FROM Claims AS T1 JOIN Settlements AS T2 ON T1.claim_id = T2.claim_id GROUP BY T1.claim_id ORDER BY count(*) DESC LIMIT 1
system: You are a text-to-SQL generator. Given a database schema and a question, reply with a single valid SQLite query that answers it. Output only the SQL on one line, with no explanation and no markdown.

user: Schema:
CREATE TABLE torrents (
  groupName text,
  totalSnatched integer,
  artist text,
  groupYear integer,
  releaseType text,
  groupId integer,
  id integer PRIMARY KEY
);
CREATE TABLE tags (
  index integer PRIMARY KEY,
  id integer,
  tag text
);

Hint: release title refers to groupName; Ron Hunt is an artist; groupYear = 1979; releaseType = 'single'; downloaded 239 times refer to totalSnatched = 239;

Question: What is the release title of the single that was released by Ron Hunt in 1979 that was downloaded 239 times?

assistant: SELECT groupName FROM torrents WHERE artist LIKE 'ron hunt & ronnie g & the sm crew' AND groupYear = 1979 AND releaseType LIKE 'single' AND totalSnatched = 239
system: You are a text-to-SQL generator. Given a database schema and a question, reply with a single valid SQLite query that answers it. Output only the SQL on one line, with no explanation and no markdown.

user: Schema:
create table Student (
        StuID        INTEGER PRIMARY KEY,
        LName        VARCHAR(12),
        Fname        VARCHAR(12),
        Age      INTEGER,
        Sex      VARCHAR(1),
        Major        INTEGER,
        Advisor      INTEGER,
        city_code    VARCHAR(3)
 );

create table Faculty (
       FacID 	       INTEGER PRIMARY KEY,
       Lname		VARCHAR(15),
       Fname		VARCHAR(15),
       Rank		VARCHAR(15),
       Sex		VARCHAR(1),
       Phone		INTEGER,
       Room		VARCHAR(5),
       Building		VARCHAR(13)
);

create table Department (
       DNO   		INTEGER PRIMARY KEY,
       Division		VARCHAR(2),
       DName		VARCHAR(25),
       Room		VARCHAR(5),
       Building		VARCHAR(13),
       DPhone		INTEGER
);

create table Member_of (
       FacID 	       INTEGER,
       DNO	       INTEGER,
       Appt_Type       VARCHAR(15),
       FOREIGN KEY(FacID) REFERENCES Faculty(FacID),
       FOREIGN KEY(DNO) REFERENCES Department(DNO)
);

create table Course (
       CID   	    	VARCHAR(7) PRIMARY KEY,
       CName		VARCHAR(40),
       Credits		INTEGER,
       Instructor	INTEGER,
       Days		VARCHAR(5),
       Hours		VARCHAR(11),
       DNO		INTEGER,
       FOREIGN KEY(Instructor) REFERENCES Faculty(FacID),
       FOREIGN KEY(DNO) REFERENCES Department(DNO)
);

create table Minor_in (
       StuID 	      INTEGER,
       DNO		INTEGER,
       FOREIGN KEY(StuID) REFERENCES Student(StuID),
       FOREIGN KEY(DNO) REFERENCES Department(DNO)
);

create table Enrolled_in (
       StuID 		 INTEGER,
       CID		VARCHAR(7),
       Grade		VARCHAR(2),
       FOREIGN KEY(StuID) REFERENCES Student(StuID),
       FOREIGN KEY(CID) REFERENCES Course(CID),
       FOREIGN KEY(Grade) REFERENCES Gradeconversion(lettergrade)
);

create table Gradeconversion (
       lettergrade	     VARCHAR(2) PRIMARY KEY,
       gradepoint	     FLOAT
);

Question: Count the number of courses.

assistant: SELECT count(*) FROM COURSE
system: You are a text-to-SQL generator. Given a database schema and a question, reply with a single valid SQLite query that answers it. Output only the SQL on one line, with no explanation and no markdown.

user: Schema:
CREATE TABLE address_status (
  status_id integer PRIMARY KEY,
  address_status text
);
CREATE TABLE author (
  author_id integer PRIMARY KEY,
  author_name text
);
CREATE TABLE book_language (
  language_id integer PRIMARY KEY,
  language_code text,
  language_name text
);
CREATE TABLE country (
  country_id integer PRIMARY KEY,
  country_name text
);
CREATE TABLE address (
  address_id integer PRIMARY KEY,
  street_number text,
  street_name text,
  city text,
  country_id integer
);
CREATE TABLE customer (
  customer_id integer PRIMARY KEY,
  first_name text,
  last_name text,
  email text
);
CREATE TABLE customer_address (
  customer_id integer PRIMARY KEY,
  address_id integer PRIMARY KEY,
  status_id integer
);
CREATE TABLE order_status (
  status_id integer PRIMARY KEY,
  status_value text
);
CREATE TABLE publisher (
  publisher_id integer PRIMARY KEY,
  publisher_name text
);
CREATE TABLE book (
  book_id integer PRIMARY KEY,
  title text,
  isbn13 text,
  language_id integer,
  num_pages integer,
  publication_date date,
  publisher_id integer
);
CREATE TABLE book_author (
  book_id integer PRIMARY KEY,
  author_id integer PRIMARY KEY
);
CREATE TABLE shipping_method (
  method_id integer PRIMARY KEY,
  method_name text,
  cost real
);
CREATE TABLE cust_order (
  order_id integer PRIMARY KEY,
  order_date datetime,
  customer_id integer,
  shipping_method_id integer,
  dest_address_id integer
);
CREATE TABLE order_history (
  history_id integer PRIMARY KEY,
  order_id integer,
  status_id integer,
  status_date datetime
);
CREATE TABLE order_line (
  line_id integer PRIMARY KEY,
  order_id integer,
  book_id integer,
  price real
);
-- foreign keys: address.country_id -> country.country_id; customer_address.customer_id -> customer.customer_id; customer_address.address_id -> address.address_id; book.publisher_id -> publisher.publisher_id; book.language_id -> book_language.language_id; book_author.book_id -> book.book_id; book_author.author_id -> author.author_id

Hint: "Thomas Nelson" is the publisher_name; books with over 300 pages refers to num_pages > 300

Question: Among the books published by publisher "Thomas Nelson", how many of them have over 300 pages?

assistant: SELECT COUNT(*) FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id WHERE T2.publisher_name = 'Thomas Nelson' AND T1.num_pages > 300
system: You are a text-to-SQL generator. Given a database schema and a question, reply with a single valid SQLite query that answers it. Output only the SQL on one line, with no explanation and no markdown.

user: Schema:
CREATE TABLE course (
  course_id integer PRIMARY KEY,
  name text,
  credit integer,
  diff integer
);
CREATE TABLE prof (
  prof_id integer PRIMARY KEY,
  gender text,
  first_name text,
  last_name text,
  email text,
  popularity integer,
  teachingability integer,
  graduate_from text
);
CREATE TABLE RA (
  student_id integer PRIMARY KEY,
  capability integer,
  prof_id integer PRIMARY KEY,
  salary text
);
CREATE TABLE registration (
  course_id integer PRIMARY KEY,
  student_id integer PRIMARY KEY,
  grade text,
  sat integer
);
CREATE TABLE student (
  student_id integer PRIMARY KEY,
  f_name text,
  l_name text,
  phone_number text,
  email text,
  intelligence integer,
  gpa real,
  type text
);
-- foreign keys: RA.student_id -> student.student_id; RA.prof_id -> prof.prof_id; registration.student_id -> student.student_id; registration.course_id -> course.course_id

Hint: highest teachability refers to MAX(teachability); high salary refers to salary = 'high';

Question: Among professors with the highest teachability, how many of their students have high salary?

assistant: SELECT COUNT(T1.student_id) FROM RA AS T1 INNER JOIN prof AS T2 ON T1.prof_id = T2.prof_id WHERE T1.salary = 'high' ORDER BY T2.teachingability DESC LIMIT 1