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 Customers (
  CustomerID integer PRIMARY KEY,
  FirstName text,
  MiddleInitial text,
  LastName text
);
CREATE TABLE Employees (
  EmployeeID integer PRIMARY KEY,
  FirstName text,
  MiddleInitial text,
  LastName text
);
CREATE TABLE Products (
  ProductID integer PRIMARY KEY,
  Name text,
  Price real
);
CREATE TABLE Sales (
  SalesID integer PRIMARY KEY,
  SalesPersonID integer,
  CustomerID integer,
  ProductID integer,
  Quantity integer
);
-- foreign keys: Sales.ProductID -> Products.ProductID; Sales.CustomerID -> Customers.CustomerID; Sales.SalesPersonID -> Employees.EmployeeID

Hint: percentage = MULTIPLY(DIVIDE(SUM(Quantity WHERE Name = 'Blade'), SUM(Quantity)), 1.0); 'blades' refers to name of product;

Question: Calculate the percentage of sold blades in the total number of transactions.

assistant: SELECT CAST(SUM(IIF(T1.Name = 'Blade', T2.Quantity, 0)) AS REAL) * 100 / SUM(T2.Quantity) FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID
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 cars (
  id integer PRIMARY KEY,
  train_id integer,
  position integer,
  shape text,
  len text,
  sides text,
  roof text,
  wheels integer,
  load_shape text,
  load_num integer
);
CREATE TABLE trains (
  id integer PRIMARY KEY,
  direction text
);
-- foreign keys: cars.train_id -> trains.id

Hint: 2nd car refers to position = 2

Question: What is the direction of the train with a diamond-shaped load in its 2nd car?

assistant: SELECT T2.direction FROM cars AS T1 INNER JOIN trains AS T2 ON T1.train_id = T2.id WHERE T1.position = 2 AND T1.shape = 'diamond'
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: A Way of Life' refers to movie_title; user 39115684 refers to userid = 39115684;  the user was a trialist when he rated the movie refers to user_trialist = 1;

Question: Was user 39115684 a trialist when he or she rated the movie "A Way of Life"?

assistant: SELECT T1.user_trialist FROM ratings AS T1 INNER JOIN movies AS T2 ON T1.movie_id = T2.movie_id WHERE T2.movie_title = 'A Way of Life' AND T1.user_id = 39115684
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 `Investors` (
`investor_id` INTEGER PRIMARY KEY,
`Investor_details` VARCHAR(255)
);

Question: Show the transaction type code that occurs the most frequently.

assistant: SELECT transaction_type_code FROM TRANSACTIONS GROUP BY transaction_type_code 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 country (
  origin integer PRIMARY KEY,
  country text
);
CREATE TABLE price (
  ID integer PRIMARY KEY,
  price real
);
CREATE TABLE data (
  ID integer PRIMARY KEY,
  mpg real,
  cylinders integer,
  displacement real,
  horsepower integer,
  weight integer,
  acceleration real,
  model integer,
  car_name text
);
CREATE TABLE production (
  ID integer PRIMARY KEY,
  model_year integer PRIMARY KEY,
  country integer
);
-- foreign keys: data.ID -> price.ID; production.ID -> price.ID; production.ID -> data.ID; production.country -> country.origin

Hint: origin country refers to country; Ford Torino refers to car_name = 'ford torino'; produced in 1970 refers to model_year = 1970

Question: What was the origin country of the car model ford torino produced in 1970?

assistant: SELECT T3.country FROM data AS T1 INNER JOIN production AS T2 ON T1.ID = T2.ID INNER JOIN country AS T3 ON T3.origin = T2.country WHERE T1.car_name = 'ford torino' AND T2.model_year = 1970
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 Dish (
  id integer PRIMARY KEY,
  name text,
  description text,
  menus_appeared integer,
  times_appeared integer,
  first_appeared integer,
  last_appeared integer,
  lowest_price real,
  highest_price real
);
CREATE TABLE Menu (
  id integer PRIMARY KEY,
  name text,
  sponsor text,
  event text,
  venue text,
  place text,
  physical_description text,
  occasion text,
  notes text,
  call_number text,
  keywords text,
  language text,
  date date,
  location text,
  location_type text,
  currency text,
  currency_symbol text,
  status text,
  page_count integer,
  dish_count integer
);
CREATE TABLE MenuPage (
  id integer PRIMARY KEY,
  menu_id integer,
  page_number integer,
  image_id real,
  full_height integer,
  full_width integer,
  uuid text
);
CREATE TABLE MenuItem (
  id integer PRIMARY KEY,
  menu_page_id integer,
  price real,
  high_price real,
  dish_id integer,
  created_at text,
  updated_at text,
  xpos real,
  ypos real
);
-- foreign keys: MenuPage.menu_id -> Menu.id; MenuItem.menu_page_id -> MenuPage.id; MenuItem.dish_id -> Dish.id

Hint: milk is a name of dish; highest price refers to MAX(price);

Question: Among the menus that include milk, what is the menu page id of the menu that has the highest price?

assistant: SELECT T1.menu_page_id FROM MenuItem AS T1 INNER JOIN Dish AS T2 ON T2.id = T1.dish_id WHERE T2.name = 'Milk' ORDER BY T1.price 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 Question (
  questiontext text,
  questionid integer PRIMARY KEY
);
CREATE TABLE Survey (
  SurveyID integer PRIMARY KEY,
  Description text
);
CREATE TABLE Answer (
  AnswerText text,
  SurveyID integer,
  UserID integer PRIMARY KEY,
  QuestionID integer PRIMARY KEY
);

Hint: survey in 2017 refers to SurveyID = 2017; questionID = 85; MAX(COUNT(AnswerText))

Question: List the top three popular responses to the question of the survey in 2017 with the question ID no.85.

assistant: SELECT AnswerText FROM Answer WHERE QuestionID = 85 AND SurveyID = 2017 GROUP BY AnswerText ORDER BY COUNT(AnswerText) DESC LIMIT 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:
PRAGMA foreign_keys = ON;
CREATE TABLE Ref_Hotel_Star_Ratings (
star_rating_code CHAR(15) NOT NULL,
star_rating_description VARCHAR(80),
PRIMARY KEY (star_rating_code),
UNIQUE (star_rating_code)
);


CREATE TABLE Locations (
Location_ID INTEGER NOT NULL,
Location_Name VARCHAR(255),
Address VARCHAR(255),
Other_Details VARCHAR(255),
PRIMARY KEY (Location_ID)
);

Question: What are the name, id and the corresponding number of visits for each  tourist attraction?

assistant: SELECT T1.Name , T2.Tourist_Attraction_ID , COUNT(*) FROM Tourist_Attractions AS T1 JOIN VISITS AS T2 ON T1.Tourist_Attraction_ID = T2.Tourist_Attraction_ID GROUP BY T2.Tourist_Attraction_ID
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 Method (
  Id integer PRIMARY KEY,
  Name text,
  FullComment text,
  Summary text,
  ApiCalls text,
  CommentIsXml integer,
  SampledAt integer,
  SolutionId integer,
  Lang text,
  NameTokenized text
);
CREATE TABLE MethodParameter (
  Id integer PRIMARY KEY,
  MethodId text,
  Type text,
  Name text
);
CREATE TABLE Repo (
  Id integer PRIMARY KEY,
  Url text,
  Stars integer,
  Forks integer,
  Watchers integer,
  ProcessedTime integer
);
CREATE TABLE Solution (
  Id integer PRIMARY KEY,
  RepoId integer,
  Path text,
  ProcessedTime integer,
  WasCompiled integer
);

Hint: solution path refers to Path; method number refers to Method_100k.Id; Method_100k.Id = 3;

Question: What is the solution path for method number 3?

assistant: SELECT T1.Path FROM Solution AS T1 INNER JOIN Method AS T2 ON T1.Id = T2.SolutionId WHERE T2.Id = 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:
PRAGMA foreign_keys = ON;

CREATE TABLE Addresses (
address_id INTEGER NOT NULL,
line_1 VARCHAR(80),
line_2 VARCHAR(80),
city VARCHAR(50),
zip_postcode CHAR(20),
state_province_county VARCHAR(50),
country VARCHAR(50),
PRIMARY KEY (address_id)
);

Question: List the id of students who attended some courses?

assistant: SELECT student_id FROM student_course_attendance
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 country (
  id integer PRIMARY KEY,
  country_name text
);
CREATE TABLE ranking_system (
  id integer PRIMARY KEY,
  system_name text
);
CREATE TABLE ranking_criteria (
  id integer PRIMARY KEY,
  ranking_system_id integer,
  criteria_name text
);
CREATE TABLE university (
  id integer PRIMARY KEY,
  country_id integer,
  university_name text
);
CREATE TABLE university_ranking_year (
  university_id integer,
  ranking_criteria_id integer,
  year integer,
  score integer
);
CREATE TABLE university_year (
  university_id integer,
  year integer,
  num_students integer,
  student_staff_ratio real,
  pct_international_students integer,
  pct_female_students integer
);
-- foreign keys: ranking_criteria.ranking_system_id -> ranking_system.id; university.country_id -> country.id; university_ranking_year.university_id -> university.id; university_ranking_year.ranking_criteria_id -> ranking_criteria.id; university_year.university_id -> university.id

Hint: Chosun University refers to university_name = 'Chosun University'; in 2015 refers to year = 2015; on "Influence Rank" refers to criteria_name = 'Influence Rank';

Question: For Chosun University, what was its score on "Influence Rank" in 2015?

assistant: SELECT T2.score FROM ranking_criteria AS T1 INNER JOIN university_ranking_year AS T2 ON T1.id = T2.ranking_criteria_id INNER JOIN university AS T3 ON T3.id = T2.university_id WHERE T3.university_name = 'Chosun University' AND T1.criteria_name = 'Influence Rank' AND T2.year = 2015
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 city (
  id integer PRIMARY KEY,
  city_name text
);
CREATE TABLE games (
  id integer PRIMARY KEY,
  games_year integer,
  games_name text,
  season text
);
CREATE TABLE games_city (
  games_id integer,
  city_id integer
);
CREATE TABLE medal (
  id integer PRIMARY KEY,
  medal_name text
);
CREATE TABLE noc_region (
  id integer PRIMARY KEY,
  noc text,
  region_name text
);
CREATE TABLE person (
  id integer PRIMARY KEY,
  full_name text,
  gender text,
  height integer,
  weight integer
);
CREATE TABLE games_competitor (
  id integer PRIMARY KEY,
  games_id integer,
  person_id integer,
  age integer
);
CREATE TABLE person_region (
  person_id integer,
  region_id integer
);
CREATE TABLE sport (
  id integer PRIMARY KEY,
  sport_name text
);
CREATE TABLE event (
  id integer PRIMARY KEY,
  sport_id integer,
  event_name text
);
CREATE TABLE competitor_event (
  event_id integer,
  competitor_id integer,
  medal_id integer
);
-- foreign keys: games_city.games_id -> games.id; games_city.city_id -> city.id; games_competitor.person_id -> person.id; games_competitor.games_id -> games.id; person_region.region_id -> noc_region.id; person_region.person_id -> person.id; event.sport_id -> sport.id; competitor_event.medal_id -> medal.id; competitor_event.event_id -> event.id; competitor_event.competitor_id -> games_competitor.id

Hint: the tallest athlete refers to id where MAX(height); from Portugal refers to region_name = 'Portugal';

Question: Give the height of the tallest athlete from Portugal.

assistant: SELECT T3.height FROM noc_region AS T1 INNER JOIN person_region AS T2 ON T1.id = T2.region_id INNER JOIN person AS T3 ON T2.person_id = T3.id WHERE T1.region_name = 'Portugal' ORDER BY T3.height 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 `Addresses` (
`address_id` INTEGER PRIMARY KEY,
`address_details` VARCHAR(255)
);

Question: Return the name and job title of the staff with the latest date assigned.

assistant: SELECT T1.staff_name , T2.job_title_code FROM staff AS T1 JOIN staff_department_assignments AS T2 ON T1.staff_id = T2.staff_id ORDER BY T2.date_assigned_to 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 Country (
  CountryCode text PRIMARY KEY,
  ShortName text,
  TableName text,
  LongName text,
  Alpha2Code text,
  CurrencyUnit text,
  SpecialNotes text,
  Region text,
  IncomeGroup text,
  Wb2Code text,
  NationalAccountsBaseYear text,
  NationalAccountsReferenceYear text,
  SnaPriceValuation text,
  LendingCategory text,
  OtherGroups text,
  SystemOfNationalAccounts text,
  AlternativeConversionFactor text,
  PppSurveyYear text,
  BalanceOfPaymentsManualInUse text,
  ExternalDebtReportingStatus text,
  SystemOfTrade text,
  GovernmentAccountingConcept text,
  ImfDataDisseminationStandard text,
  LatestPopulationCensus text,
  LatestHouseholdSurvey text,
  SourceOfMostRecentIncomeAndExpenditureData text,
  VitalRegistrationComplete text,
  LatestAgriculturalCensus text,
  LatestIndustrialData integer,
  LatestTradeData integer,
  LatestWaterWithdrawalData integer
);
CREATE TABLE Series (
  SeriesCode text PRIMARY KEY,
  Topic text,
  IndicatorName text,
  ShortDefinition text,
  LongDefinition text,
  UnitOfMeasure text,
  Periodicity text,
  BasePeriod text,
  OtherNotes integer,
  AggregationMethod text,
  LimitationsAndExceptions text,
  NotesFromOriginalSource text,
  GeneralComments text,
  Source text,
  StatisticalConceptAndMethodology text,
  DevelopmentRelevance text,
  RelatedSourceLinks text,
  OtherWebLinks integer,
  RelatedIndicators integer,
  LicenseType text
);
CREATE TABLE CountryNotes (
  Countrycode text PRIMARY KEY,
  Seriescode text PRIMARY KEY,
  Description text
);
CREATE TABLE Footnotes (
  Countrycode text PRIMARY KEY,
  Seriescode text PRIMARY KEY,
  Year text PRIMARY KEY,
  Description text
);
CREATE TABLE Indicators (
  CountryName text,
  CountryCode text PRIMARY KEY,
  IndicatorName text,
  IndicatorCode text PRIMARY KEY,
  Year integer PRIMARY KEY,
  Value integer
);
CREATE TABLE SeriesNotes (
  Seriescode text PRIMARY KEY,
  Year text PRIMARY KEY,
  Description text
);
-- foreign keys: CountryNotes.Countrycode -> Country.CountryCode; CountryNotes.Seriescode -> Series.SeriesCode; Footnotes.Countrycode -> Country.CountryCode; Footnotes.Seriescode -> Series.SeriesCode; Indicators.CountryCode -> Country.CountryCode; SeriesNotes.Seriescode -> Series.SeriesCode

Hint: countries in Europe & Central Asia refer to region = 'Europe & Central Asia'; uses Danish krone refers to currencyunit = 'Danish krone'; full name refers to longname

Question: How many countries in Europe & Central Asia uses Danish krone as its currency? List the full names of those coutnries.

assistant: SELECT COUNT(longname) FROM country WHERE region = 'Europe & Central Asia' AND currencyunit = 'Danish krone' UNION SELECT longname FROM country WHERE currencyunit = 'Danish krone' AND region = 'Europe & Central Asia'
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 country (
  origin integer PRIMARY KEY,
  country text
);
CREATE TABLE price (
  ID integer PRIMARY KEY,
  price real
);
CREATE TABLE data (
  ID integer PRIMARY KEY,
  mpg real,
  cylinders integer,
  displacement real,
  horsepower integer,
  weight integer,
  acceleration real,
  model integer,
  car_name text
);
CREATE TABLE production (
  ID integer PRIMARY KEY,
  model_year integer PRIMARY KEY,
  country integer
);
-- foreign keys: data.ID -> price.ID; production.ID -> price.ID; production.ID -> data.ID; production.country -> country.origin

Hint: American car refers to country = 'USA'; percentage = divide(count(ID where country = 'USA'), count(ID)) * 100%

Question: Calculate the percentage of American cars among all cars.

assistant: SELECT CAST(SUM(CASE WHEN T3.country = 'USA' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM data AS T1 INNER JOIN production AS T2 ON T1.ID = T2.ID INNER JOIN country AS T3 ON T3.origin = T2.country
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 chapters (
  id integer PRIMARY KEY,
  Act integer,
  Scene integer,
  Description text,
  work_id integer
);
CREATE TABLE characters (
  id integer PRIMARY KEY,
  CharName text,
  Abbrev text,
  Description text
);
CREATE TABLE paragraphs (
  id integer PRIMARY KEY,
  ParagraphNum integer,
  PlainText text,
  character_id integer,
  chapter_id integer
);
CREATE TABLE works (
  id integer PRIMARY KEY,
  Title text,
  LongTitle text,
  Date integer,
  GenreType text
);

Hint: Antony and Cleopatra refers to Title = 'Antony and Cleopatra'; average scene per act = divide(sum(Scene), count(act))

Question: Calculate average scene per act in Antony and Cleopatra.

assistant: SELECT CAST(SUM(T2.Scene) AS REAL) / COUNT(T2.act) FROM works AS T1 INNER JOIN chapters AS T2 ON T1.id = T2.work_id WHERE T1.Title = 'Antony and Cleopatra'
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: education level of 11 refers to EDUCATIONNUM = 11;

Question: Please list the occupations of the customers with an education level of 11.

assistant: SELECT DISTINCT OCCUPATION FROM Customers WHERE EDUCATIONNUM = 11
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 users (
  userid integer PRIMARY KEY,
  age text,
  u_gender text,
  occupation text
);
CREATE TABLE directors (
  directorid integer PRIMARY KEY,
  d_quality integer,
  avg_revenue integer
);
CREATE TABLE actors (
  actorid integer PRIMARY KEY,
  a_gender text,
  a_quality integer
);
CREATE TABLE movies (
  movieid integer PRIMARY KEY,
  year integer,
  isEnglish text,
  country text,
  runningtime integer
);
CREATE TABLE movies2actors (
  movieid integer PRIMARY KEY,
  actorid integer PRIMARY KEY,
  cast_num integer
);
CREATE TABLE movies2directors (
  movieid integer PRIMARY KEY,
  directorid integer PRIMARY KEY,
  genre text
);
CREATE TABLE u2base (
  userid integer PRIMARY KEY,
  movieid integer PRIMARY KEY,
  rating text
);

Question: Among the best actors, how many of them got a rating of 5 to the movies they starred?

assistant: SELECT COUNT(T1.actorid) FROM actors AS T1 INNER JOIN movies2actors AS T2 ON T1.actorid = T2.actorid INNER JOIN u2base AS T3 ON T2.movieid = T3.movieid WHERE T1.a_quality = 5 AND T3.rating = 5