Dludora/DAIL-BIRD huggingface dataset:
/* Given the following database schema: */
CREATE TABLE sqlite_sequence(name,seq)

CREATE TABLE `City` (
  `ID` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
  `Name` TEXT NOT NULL DEFAULT '',
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `District` TEXT NOT NULL DEFAULT '',
  `Population` INTEGER NOT NULL DEFAULT 0,
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

CREATE TABLE `Country` (
  `Code` TEXT NOT NULL DEFAULT '',
  `Name` TEXT NOT NULL DEFAULT '',
  `Continent` TEXT NOT NULL DEFAULT 'Asia',
  `Region` TEXT NOT NULL DEFAULT '',
  `SurfaceArea` REAL NOT NULL DEFAULT 0.00,
  `IndepYear` INTEGER DEFAULT NULL,
  `Population` INTEGER NOT NULL DEFAULT 0,
  `LifeExpectancy` REAL DEFAULT NULL,
  `GNP` REAL DEFAULT NULL,
  `GNPOld` REAL DEFAULT NULL,
  `LocalName` TEXT NOT NULL DEFAULT '',
  `GovernmentForm` TEXT NOT NULL DEFAULT '',
  `HeadOfState` TEXT DEFAULT NULL,
  `Capital` INTEGER DEFAULT NULL,
  `Code2` TEXT NOT NULL DEFAULT '',
  PRIMARY KEY (`Code`)
)

CREATE TABLE `CountryLanguage` (
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `Language` TEXT NOT NULL DEFAULT '',
  `IsOfficial`TEXT NOT NULL DEFAULT 'F',
  `Percentage` REAL NOT NULL DEFAULT 0.0,
  PRIMARY KEY (`CountryCode`,`Language`),
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

/* Answer the following: List the languages used in the USA. USA refers to CountryCode = 'USA'; */
SELECT 
SELECT Language FROM CountryLanguage WHERE CountryCode = 'USA'
/* Given the following database schema: */
CREATE TABLE sqlite_sequence(name,seq)

CREATE TABLE `City` (
  `ID` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
  `Name` TEXT NOT NULL DEFAULT '',
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `District` TEXT NOT NULL DEFAULT '',
  `Population` INTEGER NOT NULL DEFAULT 0,
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

CREATE TABLE `Country` (
  `Code` TEXT NOT NULL DEFAULT '',
  `Name` TEXT NOT NULL DEFAULT '',
  `Continent` TEXT NOT NULL DEFAULT 'Asia',
  `Region` TEXT NOT NULL DEFAULT '',
  `SurfaceArea` REAL NOT NULL DEFAULT 0.00,
  `IndepYear` INTEGER DEFAULT NULL,
  `Population` INTEGER NOT NULL DEFAULT 0,
  `LifeExpectancy` REAL DEFAULT NULL,
  `GNP` REAL DEFAULT NULL,
  `GNPOld` REAL DEFAULT NULL,
  `LocalName` TEXT NOT NULL DEFAULT '',
  `GovernmentForm` TEXT NOT NULL DEFAULT '',
  `HeadOfState` TEXT DEFAULT NULL,
  `Capital` INTEGER DEFAULT NULL,
  `Code2` TEXT NOT NULL DEFAULT '',
  PRIMARY KEY (`Code`)
)

CREATE TABLE `CountryLanguage` (
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `Language` TEXT NOT NULL DEFAULT '',
  `IsOfficial`TEXT NOT NULL DEFAULT 'F',
  `Percentage` REAL NOT NULL DEFAULT 0.0,
  PRIMARY KEY (`CountryCode`,`Language`),
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

/* Answer the following: How many countries use Portuguese? Portuguese refers to `Language` = 'Portuguese'; */
SELECT 
SELECT SUM(CASE WHEN Language = 'Portuguese' THEN 1 ELSE 0 END) FROM CountryLanguage
/* Given the following database schema: */
CREATE TABLE sqlite_sequence(name,seq)

CREATE TABLE `City` (
  `ID` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
  `Name` TEXT NOT NULL DEFAULT '',
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `District` TEXT NOT NULL DEFAULT '',
  `Population` INTEGER NOT NULL DEFAULT 0,
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

CREATE TABLE `Country` (
  `Code` TEXT NOT NULL DEFAULT '',
  `Name` TEXT NOT NULL DEFAULT '',
  `Continent` TEXT NOT NULL DEFAULT 'Asia',
  `Region` TEXT NOT NULL DEFAULT '',
  `SurfaceArea` REAL NOT NULL DEFAULT 0.00,
  `IndepYear` INTEGER DEFAULT NULL,
  `Population` INTEGER NOT NULL DEFAULT 0,
  `LifeExpectancy` REAL DEFAULT NULL,
  `GNP` REAL DEFAULT NULL,
  `GNPOld` REAL DEFAULT NULL,
  `LocalName` TEXT NOT NULL DEFAULT '',
  `GovernmentForm` TEXT NOT NULL DEFAULT '',
  `HeadOfState` TEXT DEFAULT NULL,
  `Capital` INTEGER DEFAULT NULL,
  `Code2` TEXT NOT NULL DEFAULT '',
  PRIMARY KEY (`Code`)
)

CREATE TABLE `CountryLanguage` (
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `Language` TEXT NOT NULL DEFAULT '',
  `IsOfficial`TEXT NOT NULL DEFAULT 'F',
  `Percentage` REAL NOT NULL DEFAULT 0.0,
  PRIMARY KEY (`CountryCode`,`Language`),
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

/* Answer the following: How many cities are there in England? England refers to District = 'England'; */
SELECT 
SELECT COUNT(ID) FROM City WHERE District = 'England'
/* Given the following database schema: */
CREATE TABLE sqlite_sequence(name,seq)

CREATE TABLE `City` (
  `ID` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
  `Name` TEXT NOT NULL DEFAULT '',
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `District` TEXT NOT NULL DEFAULT '',
  `Population` INTEGER NOT NULL DEFAULT 0,
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

CREATE TABLE `Country` (
  `Code` TEXT NOT NULL DEFAULT '',
  `Name` TEXT NOT NULL DEFAULT '',
  `Continent` TEXT NOT NULL DEFAULT 'Asia',
  `Region` TEXT NOT NULL DEFAULT '',
  `SurfaceArea` REAL NOT NULL DEFAULT 0.00,
  `IndepYear` INTEGER DEFAULT NULL,
  `Population` INTEGER NOT NULL DEFAULT 0,
  `LifeExpectancy` REAL DEFAULT NULL,
  `GNP` REAL DEFAULT NULL,
  `GNPOld` REAL DEFAULT NULL,
  `LocalName` TEXT NOT NULL DEFAULT '',
  `GovernmentForm` TEXT NOT NULL DEFAULT '',
  `HeadOfState` TEXT DEFAULT NULL,
  `Capital` INTEGER DEFAULT NULL,
  `Code2` TEXT NOT NULL DEFAULT '',
  PRIMARY KEY (`Code`)
)

CREATE TABLE `CountryLanguage` (
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `Language` TEXT NOT NULL DEFAULT '',
  `IsOfficial`TEXT NOT NULL DEFAULT 'F',
  `Percentage` REAL NOT NULL DEFAULT 0.0,
  PRIMARY KEY (`CountryCode`,`Language`),
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

/* Answer the following: How many cities are there in the country with the largest surface area? largest surface area refers to MAX(SurfaceArea); */
SELECT 
SELECT T2.ID FROM Country AS T1 INNER JOIN City AS T2 ON T1.Code = T2.CountryCode WHERE T1.SurfaceArea = ( SELECT MAX(SurfaceArea) FROM Country )
/* Given the following database schema: */
CREATE TABLE sqlite_sequence(name,seq)

CREATE TABLE `City` (
  `ID` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
  `Name` TEXT NOT NULL DEFAULT '',
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `District` TEXT NOT NULL DEFAULT '',
  `Population` INTEGER NOT NULL DEFAULT 0,
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

CREATE TABLE `Country` (
  `Code` TEXT NOT NULL DEFAULT '',
  `Name` TEXT NOT NULL DEFAULT '',
  `Continent` TEXT NOT NULL DEFAULT 'Asia',
  `Region` TEXT NOT NULL DEFAULT '',
  `SurfaceArea` REAL NOT NULL DEFAULT 0.00,
  `IndepYear` INTEGER DEFAULT NULL,
  `Population` INTEGER NOT NULL DEFAULT 0,
  `LifeExpectancy` REAL DEFAULT NULL,
  `GNP` REAL DEFAULT NULL,
  `GNPOld` REAL DEFAULT NULL,
  `LocalName` TEXT NOT NULL DEFAULT '',
  `GovernmentForm` TEXT NOT NULL DEFAULT '',
  `HeadOfState` TEXT DEFAULT NULL,
  `Capital` INTEGER DEFAULT NULL,
  `Code2` TEXT NOT NULL DEFAULT '',
  PRIMARY KEY (`Code`)
)

CREATE TABLE `CountryLanguage` (
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `Language` TEXT NOT NULL DEFAULT '',
  `IsOfficial`TEXT NOT NULL DEFAULT 'F',
  `Percentage` REAL NOT NULL DEFAULT 0.0,
  PRIMARY KEY (`CountryCode`,`Language`),
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

/* Answer the following: What is the capital city and population of San Marino? capital city refers to Capital; San Marino is a name of country; */
SELECT 
SELECT T1.Capital, T2.Population FROM Country AS T1 INNER JOIN City AS T2 ON T1.Code = T2.CountryCode WHERE T1.Name = 'San Marino'
/* Given the following database schema: */
CREATE TABLE sqlite_sequence(name,seq)

CREATE TABLE `City` (
  `ID` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
  `Name` TEXT NOT NULL DEFAULT '',
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `District` TEXT NOT NULL DEFAULT '',
  `Population` INTEGER NOT NULL DEFAULT 0,
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

CREATE TABLE `Country` (
  `Code` TEXT NOT NULL DEFAULT '',
  `Name` TEXT NOT NULL DEFAULT '',
  `Continent` TEXT NOT NULL DEFAULT 'Asia',
  `Region` TEXT NOT NULL DEFAULT '',
  `SurfaceArea` REAL NOT NULL DEFAULT 0.00,
  `IndepYear` INTEGER DEFAULT NULL,
  `Population` INTEGER NOT NULL DEFAULT 0,
  `LifeExpectancy` REAL DEFAULT NULL,
  `GNP` REAL DEFAULT NULL,
  `GNPOld` REAL DEFAULT NULL,
  `LocalName` TEXT NOT NULL DEFAULT '',
  `GovernmentForm` TEXT NOT NULL DEFAULT '',
  `HeadOfState` TEXT DEFAULT NULL,
  `Capital` INTEGER DEFAULT NULL,
  `Code2` TEXT NOT NULL DEFAULT '',
  PRIMARY KEY (`Code`)
)

CREATE TABLE `CountryLanguage` (
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `Language` TEXT NOT NULL DEFAULT '',
  `IsOfficial`TEXT NOT NULL DEFAULT 'F',
  `Percentage` REAL NOT NULL DEFAULT 0.0,
  PRIMARY KEY (`CountryCode`,`Language`),
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

/* Answer the following: List the languages used in Turkmenistan. Turkmenistan is a name of country; */
SELECT 
SELECT T2.Language FROM Country AS T1 INNER JOIN CountryLanguage AS T2 ON T1.Code = T2.CountryCode WHERE T1.Name = 'Turkmenistan'
/* Given the following database schema: */
CREATE TABLE sqlite_sequence(name,seq)

CREATE TABLE `City` (
  `ID` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
  `Name` TEXT NOT NULL DEFAULT '',
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `District` TEXT NOT NULL DEFAULT '',
  `Population` INTEGER NOT NULL DEFAULT 0,
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

CREATE TABLE `Country` (
  `Code` TEXT NOT NULL DEFAULT '',
  `Name` TEXT NOT NULL DEFAULT '',
  `Continent` TEXT NOT NULL DEFAULT 'Asia',
  `Region` TEXT NOT NULL DEFAULT '',
  `SurfaceArea` REAL NOT NULL DEFAULT 0.00,
  `IndepYear` INTEGER DEFAULT NULL,
  `Population` INTEGER NOT NULL DEFAULT 0,
  `LifeExpectancy` REAL DEFAULT NULL,
  `GNP` REAL DEFAULT NULL,
  `GNPOld` REAL DEFAULT NULL,
  `LocalName` TEXT NOT NULL DEFAULT '',
  `GovernmentForm` TEXT NOT NULL DEFAULT '',
  `HeadOfState` TEXT DEFAULT NULL,
  `Capital` INTEGER DEFAULT NULL,
  `Code2` TEXT NOT NULL DEFAULT '',
  PRIMARY KEY (`Code`)
)

CREATE TABLE `CountryLanguage` (
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `Language` TEXT NOT NULL DEFAULT '',
  `IsOfficial`TEXT NOT NULL DEFAULT 'F',
  `Percentage` REAL NOT NULL DEFAULT 0.0,
  PRIMARY KEY (`CountryCode`,`Language`),
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

/* Answer the following: Provide the name, capital city and its official language of the country with the highest life expectancy. capital city refers to Capital; official language refers to IsOfficial = 'T'; highest life expectancy refers to MAX(LifeExpectancy); */
SELECT 
SELECT T1.Name, T1.Capital, T2.Language FROM Country AS T1 INNER JOIN CountryLanguage AS T2 ON T1.Code = T2.CountryCode INNER JOIN City AS T3 ON T1.Code = T3.CountryCode WHERE T2.IsOfficial = 'T' ORDER BY T1.LifeExpectancy DESC LIMIT 1
/* Given the following database schema: */
CREATE TABLE sqlite_sequence(name,seq)

CREATE TABLE `City` (
  `ID` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
  `Name` TEXT NOT NULL DEFAULT '',
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `District` TEXT NOT NULL DEFAULT '',
  `Population` INTEGER NOT NULL DEFAULT 0,
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

CREATE TABLE `Country` (
  `Code` TEXT NOT NULL DEFAULT '',
  `Name` TEXT NOT NULL DEFAULT '',
  `Continent` TEXT NOT NULL DEFAULT 'Asia',
  `Region` TEXT NOT NULL DEFAULT '',
  `SurfaceArea` REAL NOT NULL DEFAULT 0.00,
  `IndepYear` INTEGER DEFAULT NULL,
  `Population` INTEGER NOT NULL DEFAULT 0,
  `LifeExpectancy` REAL DEFAULT NULL,
  `GNP` REAL DEFAULT NULL,
  `GNPOld` REAL DEFAULT NULL,
  `LocalName` TEXT NOT NULL DEFAULT '',
  `GovernmentForm` TEXT NOT NULL DEFAULT '',
  `HeadOfState` TEXT DEFAULT NULL,
  `Capital` INTEGER DEFAULT NULL,
  `Code2` TEXT NOT NULL DEFAULT '',
  PRIMARY KEY (`Code`)
)

CREATE TABLE `CountryLanguage` (
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `Language` TEXT NOT NULL DEFAULT '',
  `IsOfficial`TEXT NOT NULL DEFAULT 'F',
  `Percentage` REAL NOT NULL DEFAULT 0.0,
  PRIMARY KEY (`CountryCode`,`Language`),
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

/* Answer the following: List the countries and their official languages in Antarctica. official language refers to IsOfficial = 'T'; Antarctica refers to Continent = 'Antarctica'; */
SELECT 
SELECT T1.Name, T2.Language FROM Country AS T1 INNER JOIN CountryLanguage AS T2 ON T1.Code = T2.CountryCode WHERE T1.Continent = 'Antarctica' AND T2.IsOfficial = 'T'
/* Given the following database schema: */
CREATE TABLE sqlite_sequence(name,seq)

CREATE TABLE `City` (
  `ID` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
  `Name` TEXT NOT NULL DEFAULT '',
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `District` TEXT NOT NULL DEFAULT '',
  `Population` INTEGER NOT NULL DEFAULT 0,
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

CREATE TABLE `Country` (
  `Code` TEXT NOT NULL DEFAULT '',
  `Name` TEXT NOT NULL DEFAULT '',
  `Continent` TEXT NOT NULL DEFAULT 'Asia',
  `Region` TEXT NOT NULL DEFAULT '',
  `SurfaceArea` REAL NOT NULL DEFAULT 0.00,
  `IndepYear` INTEGER DEFAULT NULL,
  `Population` INTEGER NOT NULL DEFAULT 0,
  `LifeExpectancy` REAL DEFAULT NULL,
  `GNP` REAL DEFAULT NULL,
  `GNPOld` REAL DEFAULT NULL,
  `LocalName` TEXT NOT NULL DEFAULT '',
  `GovernmentForm` TEXT NOT NULL DEFAULT '',
  `HeadOfState` TEXT DEFAULT NULL,
  `Capital` INTEGER DEFAULT NULL,
  `Code2` TEXT NOT NULL DEFAULT '',
  PRIMARY KEY (`Code`)
)

CREATE TABLE `CountryLanguage` (
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `Language` TEXT NOT NULL DEFAULT '',
  `IsOfficial`TEXT NOT NULL DEFAULT 'F',
  `Percentage` REAL NOT NULL DEFAULT 0.0,
  PRIMARY KEY (`CountryCode`,`Language`),
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

/* Answer the following: Among the languages used in Baltic Countries, provide the languages which are used by over 80%.

 Baltic Countries refers to Region = 'Baltic Countries'; languages which are used by over 80% refers to Percentage > 80; */
SELECT 
SELECT T2.Language FROM Country AS T1 INNER JOIN CountryLanguage AS T2 ON T1.Code = T2.CountryCode WHERE T1.Region = 'Baltic Countries' AND T2.Percentage > 80
/* Given the following database schema: */
CREATE TABLE sqlite_sequence(name,seq)

CREATE TABLE `City` (
  `ID` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
  `Name` TEXT NOT NULL DEFAULT '',
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `District` TEXT NOT NULL DEFAULT '',
  `Population` INTEGER NOT NULL DEFAULT 0,
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

CREATE TABLE `Country` (
  `Code` TEXT NOT NULL DEFAULT '',
  `Name` TEXT NOT NULL DEFAULT '',
  `Continent` TEXT NOT NULL DEFAULT 'Asia',
  `Region` TEXT NOT NULL DEFAULT '',
  `SurfaceArea` REAL NOT NULL DEFAULT 0.00,
  `IndepYear` INTEGER DEFAULT NULL,
  `Population` INTEGER NOT NULL DEFAULT 0,
  `LifeExpectancy` REAL DEFAULT NULL,
  `GNP` REAL DEFAULT NULL,
  `GNPOld` REAL DEFAULT NULL,
  `LocalName` TEXT NOT NULL DEFAULT '',
  `GovernmentForm` TEXT NOT NULL DEFAULT '',
  `HeadOfState` TEXT DEFAULT NULL,
  `Capital` INTEGER DEFAULT NULL,
  `Code2` TEXT NOT NULL DEFAULT '',
  PRIMARY KEY (`Code`)
)

CREATE TABLE `CountryLanguage` (
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `Language` TEXT NOT NULL DEFAULT '',
  `IsOfficial`TEXT NOT NULL DEFAULT 'F',
  `Percentage` REAL NOT NULL DEFAULT 0.0,
  PRIMARY KEY (`CountryCode`,`Language`),
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

/* Answer the following: Among the languages used in Baltic Countries, provide the languages which are used by over 80%. Baltic Countries refers to Region = 'Baltic Countries'; languages which are used by over 80% refers to Percentage > 80; */
SELECT 
SELECT T2.Language FROM Country AS T1 INNER JOIN CountryLanguage AS T2 ON T1.Code = T2.CountryCode WHERE T1.Region = 'Baltic Countries' AND T2.Percentage > 80
/* Given the following database schema: */
CREATE TABLE sqlite_sequence(name,seq)

CREATE TABLE `City` (
  `ID` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
  `Name` TEXT NOT NULL DEFAULT '',
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `District` TEXT NOT NULL DEFAULT '',
  `Population` INTEGER NOT NULL DEFAULT 0,
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

CREATE TABLE `Country` (
  `Code` TEXT NOT NULL DEFAULT '',
  `Name` TEXT NOT NULL DEFAULT '',
  `Continent` TEXT NOT NULL DEFAULT 'Asia',
  `Region` TEXT NOT NULL DEFAULT '',
  `SurfaceArea` REAL NOT NULL DEFAULT 0.00,
  `IndepYear` INTEGER DEFAULT NULL,
  `Population` INTEGER NOT NULL DEFAULT 0,
  `LifeExpectancy` REAL DEFAULT NULL,
  `GNP` REAL DEFAULT NULL,
  `GNPOld` REAL DEFAULT NULL,
  `LocalName` TEXT NOT NULL DEFAULT '',
  `GovernmentForm` TEXT NOT NULL DEFAULT '',
  `HeadOfState` TEXT DEFAULT NULL,
  `Capital` INTEGER DEFAULT NULL,
  `Code2` TEXT NOT NULL DEFAULT '',
  PRIMARY KEY (`Code`)
)

CREATE TABLE `CountryLanguage` (
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `Language` TEXT NOT NULL DEFAULT '',
  `IsOfficial`TEXT NOT NULL DEFAULT 'F',
  `Percentage` REAL NOT NULL DEFAULT 0.0,
  PRIMARY KEY (`CountryCode`,`Language`),
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

/* Answer the following: Provide the name, located country, and life expectancy of the most populated city most populated city refers to MAX(Population); */
SELECT 
SELECT T2.Name, T1.Code, T1.LifeExpectancy FROM Country AS T1 INNER JOIN City AS T2 ON T1.Code = T2.CountryCode ORDER BY T2.Population DESC LIMIT 1
/* Given the following database schema: */
CREATE TABLE sqlite_sequence(name,seq)

CREATE TABLE `City` (
  `ID` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
  `Name` TEXT NOT NULL DEFAULT '',
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `District` TEXT NOT NULL DEFAULT '',
  `Population` INTEGER NOT NULL DEFAULT 0,
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

CREATE TABLE `Country` (
  `Code` TEXT NOT NULL DEFAULT '',
  `Name` TEXT NOT NULL DEFAULT '',
  `Continent` TEXT NOT NULL DEFAULT 'Asia',
  `Region` TEXT NOT NULL DEFAULT '',
  `SurfaceArea` REAL NOT NULL DEFAULT 0.00,
  `IndepYear` INTEGER DEFAULT NULL,
  `Population` INTEGER NOT NULL DEFAULT 0,
  `LifeExpectancy` REAL DEFAULT NULL,
  `GNP` REAL DEFAULT NULL,
  `GNPOld` REAL DEFAULT NULL,
  `LocalName` TEXT NOT NULL DEFAULT '',
  `GovernmentForm` TEXT NOT NULL DEFAULT '',
  `HeadOfState` TEXT DEFAULT NULL,
  `Capital` INTEGER DEFAULT NULL,
  `Code2` TEXT NOT NULL DEFAULT '',
  PRIMARY KEY (`Code`)
)

CREATE TABLE `CountryLanguage` (
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `Language` TEXT NOT NULL DEFAULT '',
  `IsOfficial`TEXT NOT NULL DEFAULT 'F',
  `Percentage` REAL NOT NULL DEFAULT 0.0,
  PRIMARY KEY (`CountryCode`,`Language`),
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

/* Answer the following: Describe the capital city and languages used in the country with the shortest life expectancy. capital city refers to Capital; shortest life expectancy refers to MIN(LifeExpectancy); */
SELECT 
SELECT T1.Capital, T2.Language FROM Country AS T1 INNER JOIN CountryLanguage AS T2 ON T1.Code = T2.CountryCode INNER JOIN City AS T3 ON T1.Code = T3.CountryCode ORDER BY T1.LifeExpectancy LIMIT 1
/* Given the following database schema: */
CREATE TABLE sqlite_sequence(name,seq)

CREATE TABLE `City` (
  `ID` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
  `Name` TEXT NOT NULL DEFAULT '',
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `District` TEXT NOT NULL DEFAULT '',
  `Population` INTEGER NOT NULL DEFAULT 0,
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

CREATE TABLE `Country` (
  `Code` TEXT NOT NULL DEFAULT '',
  `Name` TEXT NOT NULL DEFAULT '',
  `Continent` TEXT NOT NULL DEFAULT 'Asia',
  `Region` TEXT NOT NULL DEFAULT '',
  `SurfaceArea` REAL NOT NULL DEFAULT 0.00,
  `IndepYear` INTEGER DEFAULT NULL,
  `Population` INTEGER NOT NULL DEFAULT 0,
  `LifeExpectancy` REAL DEFAULT NULL,
  `GNP` REAL DEFAULT NULL,
  `GNPOld` REAL DEFAULT NULL,
  `LocalName` TEXT NOT NULL DEFAULT '',
  `GovernmentForm` TEXT NOT NULL DEFAULT '',
  `HeadOfState` TEXT DEFAULT NULL,
  `Capital` INTEGER DEFAULT NULL,
  `Code2` TEXT NOT NULL DEFAULT '',
  PRIMARY KEY (`Code`)
)

CREATE TABLE `CountryLanguage` (
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `Language` TEXT NOT NULL DEFAULT '',
  `IsOfficial`TEXT NOT NULL DEFAULT 'F',
  `Percentage` REAL NOT NULL DEFAULT 0.0,
  PRIMARY KEY (`CountryCode`,`Language`),
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

/* Answer the following: Provide the country, population, capital city, and official language of the country with the smallest surface area. capital city refers to Capital; official language refers to IsOfficial = 'T'; smallest surface area refers to MIN(SurfaceArea); */
SELECT 
SELECT T1.Name, T1.Population, T1.Capital, T2.Language FROM Country AS T1 INNER JOIN CountryLanguage AS T2 ON T1.Code = T2.CountryCode INNER JOIN City AS T3 ON T1.Code = T3.CountryCode WHERE T2.IsOfficial = 'T' ORDER BY T1.SurfaceArea LIMIT 1
/* Given the following database schema: */
CREATE TABLE sqlite_sequence(name,seq)

CREATE TABLE `City` (
  `ID` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
  `Name` TEXT NOT NULL DEFAULT '',
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `District` TEXT NOT NULL DEFAULT '',
  `Population` INTEGER NOT NULL DEFAULT 0,
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

CREATE TABLE `Country` (
  `Code` TEXT NOT NULL DEFAULT '',
  `Name` TEXT NOT NULL DEFAULT '',
  `Continent` TEXT NOT NULL DEFAULT 'Asia',
  `Region` TEXT NOT NULL DEFAULT '',
  `SurfaceArea` REAL NOT NULL DEFAULT 0.00,
  `IndepYear` INTEGER DEFAULT NULL,
  `Population` INTEGER NOT NULL DEFAULT 0,
  `LifeExpectancy` REAL DEFAULT NULL,
  `GNP` REAL DEFAULT NULL,
  `GNPOld` REAL DEFAULT NULL,
  `LocalName` TEXT NOT NULL DEFAULT '',
  `GovernmentForm` TEXT NOT NULL DEFAULT '',
  `HeadOfState` TEXT DEFAULT NULL,
  `Capital` INTEGER DEFAULT NULL,
  `Code2` TEXT NOT NULL DEFAULT '',
  PRIMARY KEY (`Code`)
)

CREATE TABLE `CountryLanguage` (
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `Language` TEXT NOT NULL DEFAULT '',
  `IsOfficial`TEXT NOT NULL DEFAULT 'F',
  `Percentage` REAL NOT NULL DEFAULT 0.0,
  PRIMARY KEY (`CountryCode`,`Language`),
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

/* Answer the following: How many percent of countries in North America use English? percentage = MULTIPLY(DIVIDE(COUNT(Language = 'English' WHERE Continent = 'North America'), COUNT(Language WHERE Continent = 'North America')), 1.0); North America refers to Continent = 'North America'; use English refers to Language = 'English'; */
SELECT 
SELECT CAST(SUM(IIF(T2.Language = 'English', 1, 0)) AS REAL) * 100 / COUNT(T1.Code) FROM Country AS T1 INNER JOIN CountryLanguage AS T2 ON T1.Code = T2.CountryCode
/* Given the following database schema: */
CREATE TABLE sqlite_sequence(name,seq)

CREATE TABLE `City` (
  `ID` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
  `Name` TEXT NOT NULL DEFAULT '',
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `District` TEXT NOT NULL DEFAULT '',
  `Population` INTEGER NOT NULL DEFAULT 0,
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

CREATE TABLE `Country` (
  `Code` TEXT NOT NULL DEFAULT '',
  `Name` TEXT NOT NULL DEFAULT '',
  `Continent` TEXT NOT NULL DEFAULT 'Asia',
  `Region` TEXT NOT NULL DEFAULT '',
  `SurfaceArea` REAL NOT NULL DEFAULT 0.00,
  `IndepYear` INTEGER DEFAULT NULL,
  `Population` INTEGER NOT NULL DEFAULT 0,
  `LifeExpectancy` REAL DEFAULT NULL,
  `GNP` REAL DEFAULT NULL,
  `GNPOld` REAL DEFAULT NULL,
  `LocalName` TEXT NOT NULL DEFAULT '',
  `GovernmentForm` TEXT NOT NULL DEFAULT '',
  `HeadOfState` TEXT DEFAULT NULL,
  `Capital` INTEGER DEFAULT NULL,
  `Code2` TEXT NOT NULL DEFAULT '',
  PRIMARY KEY (`Code`)
)

CREATE TABLE `CountryLanguage` (
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `Language` TEXT NOT NULL DEFAULT '',
  `IsOfficial`TEXT NOT NULL DEFAULT 'F',
  `Percentage` REAL NOT NULL DEFAULT 0.0,
  PRIMARY KEY (`CountryCode`,`Language`),
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

/* Answer the following: List the district name of the city with the smallest population. smallest population refers to MIN(Population); */
SELECT 
SELECT District FROM City ORDER BY Population LIMIT 1
/* Given the following database schema: */
CREATE TABLE sqlite_sequence(name,seq)

CREATE TABLE `City` (
  `ID` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
  `Name` TEXT NOT NULL DEFAULT '',
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `District` TEXT NOT NULL DEFAULT '',
  `Population` INTEGER NOT NULL DEFAULT 0,
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

CREATE TABLE `Country` (
  `Code` TEXT NOT NULL DEFAULT '',
  `Name` TEXT NOT NULL DEFAULT '',
  `Continent` TEXT NOT NULL DEFAULT 'Asia',
  `Region` TEXT NOT NULL DEFAULT '',
  `SurfaceArea` REAL NOT NULL DEFAULT 0.00,
  `IndepYear` INTEGER DEFAULT NULL,
  `Population` INTEGER NOT NULL DEFAULT 0,
  `LifeExpectancy` REAL DEFAULT NULL,
  `GNP` REAL DEFAULT NULL,
  `GNPOld` REAL DEFAULT NULL,
  `LocalName` TEXT NOT NULL DEFAULT '',
  `GovernmentForm` TEXT NOT NULL DEFAULT '',
  `HeadOfState` TEXT DEFAULT NULL,
  `Capital` INTEGER DEFAULT NULL,
  `Code2` TEXT NOT NULL DEFAULT '',
  PRIMARY KEY (`Code`)
)

CREATE TABLE `CountryLanguage` (
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `Language` TEXT NOT NULL DEFAULT '',
  `IsOfficial`TEXT NOT NULL DEFAULT 'F',
  `Percentage` REAL NOT NULL DEFAULT 0.0,
  PRIMARY KEY (`CountryCode`,`Language`),
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

/* Answer the following: In which continent does the country with the smallest surface area belongs? smallest surface area refers to MIN(smallest surface area); */
SELECT 
SELECT Continent FROM Country ORDER BY SurfaceArea LIMIT 1
/* Given the following database schema: */
CREATE TABLE sqlite_sequence(name,seq)

CREATE TABLE `City` (
  `ID` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
  `Name` TEXT NOT NULL DEFAULT '',
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `District` TEXT NOT NULL DEFAULT '',
  `Population` INTEGER NOT NULL DEFAULT 0,
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

CREATE TABLE `Country` (
  `Code` TEXT NOT NULL DEFAULT '',
  `Name` TEXT NOT NULL DEFAULT '',
  `Continent` TEXT NOT NULL DEFAULT 'Asia',
  `Region` TEXT NOT NULL DEFAULT '',
  `SurfaceArea` REAL NOT NULL DEFAULT 0.00,
  `IndepYear` INTEGER DEFAULT NULL,
  `Population` INTEGER NOT NULL DEFAULT 0,
  `LifeExpectancy` REAL DEFAULT NULL,
  `GNP` REAL DEFAULT NULL,
  `GNPOld` REAL DEFAULT NULL,
  `LocalName` TEXT NOT NULL DEFAULT '',
  `GovernmentForm` TEXT NOT NULL DEFAULT '',
  `HeadOfState` TEXT DEFAULT NULL,
  `Capital` INTEGER DEFAULT NULL,
  `Code2` TEXT NOT NULL DEFAULT '',
  PRIMARY KEY (`Code`)
)

CREATE TABLE `CountryLanguage` (
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `Language` TEXT NOT NULL DEFAULT '',
  `IsOfficial`TEXT NOT NULL DEFAULT 'F',
  `Percentage` REAL NOT NULL DEFAULT 0.0,
  PRIMARY KEY (`CountryCode`,`Language`),
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

/* Answer the following: Who is the head of the state where the most crowded city belongs? head of the state refers to HeadOfState; most crowded city refers to MAX(Population); */
SELECT 
SELECT T1.HeadOfState FROM Country AS T1 INNER JOIN City AS T2 ON T1.Code = T2.CountryCode ORDER BY T2.Population DESC LIMIT 1
/* Given the following database schema: */
CREATE TABLE sqlite_sequence(name,seq)

CREATE TABLE `City` (
  `ID` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
  `Name` TEXT NOT NULL DEFAULT '',
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `District` TEXT NOT NULL DEFAULT '',
  `Population` INTEGER NOT NULL DEFAULT 0,
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

CREATE TABLE `Country` (
  `Code` TEXT NOT NULL DEFAULT '',
  `Name` TEXT NOT NULL DEFAULT '',
  `Continent` TEXT NOT NULL DEFAULT 'Asia',
  `Region` TEXT NOT NULL DEFAULT '',
  `SurfaceArea` REAL NOT NULL DEFAULT 0.00,
  `IndepYear` INTEGER DEFAULT NULL,
  `Population` INTEGER NOT NULL DEFAULT 0,
  `LifeExpectancy` REAL DEFAULT NULL,
  `GNP` REAL DEFAULT NULL,
  `GNPOld` REAL DEFAULT NULL,
  `LocalName` TEXT NOT NULL DEFAULT '',
  `GovernmentForm` TEXT NOT NULL DEFAULT '',
  `HeadOfState` TEXT DEFAULT NULL,
  `Capital` INTEGER DEFAULT NULL,
  `Code2` TEXT NOT NULL DEFAULT '',
  PRIMARY KEY (`Code`)
)

CREATE TABLE `CountryLanguage` (
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `Language` TEXT NOT NULL DEFAULT '',
  `IsOfficial`TEXT NOT NULL DEFAULT 'F',
  `Percentage` REAL NOT NULL DEFAULT 0.0,
  PRIMARY KEY (`CountryCode`,`Language`),
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

/* Answer the following: Among the countries that officially use the English language, what country has the highest capital? officially use the English language refers to `Language` = 'English' AND IsOfficial = 'T'; highest capital refers to MAX(Capital); */
SELECT 
SELECT T1.Code FROM Country AS T1 INNER JOIN CountryLanguage AS T2 ON T1.Code = T2.CountryCode WHERE T2.Language = 'English' AND T2.IsOfficial = 'T' ORDER BY T1.Capital DESC LIMIT 1
/* Given the following database schema: */
CREATE TABLE sqlite_sequence(name,seq)

CREATE TABLE `City` (
  `ID` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
  `Name` TEXT NOT NULL DEFAULT '',
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `District` TEXT NOT NULL DEFAULT '',
  `Population` INTEGER NOT NULL DEFAULT 0,
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

CREATE TABLE `Country` (
  `Code` TEXT NOT NULL DEFAULT '',
  `Name` TEXT NOT NULL DEFAULT '',
  `Continent` TEXT NOT NULL DEFAULT 'Asia',
  `Region` TEXT NOT NULL DEFAULT '',
  `SurfaceArea` REAL NOT NULL DEFAULT 0.00,
  `IndepYear` INTEGER DEFAULT NULL,
  `Population` INTEGER NOT NULL DEFAULT 0,
  `LifeExpectancy` REAL DEFAULT NULL,
  `GNP` REAL DEFAULT NULL,
  `GNPOld` REAL DEFAULT NULL,
  `LocalName` TEXT NOT NULL DEFAULT '',
  `GovernmentForm` TEXT NOT NULL DEFAULT '',
  `HeadOfState` TEXT DEFAULT NULL,
  `Capital` INTEGER DEFAULT NULL,
  `Code2` TEXT NOT NULL DEFAULT '',
  PRIMARY KEY (`Code`)
)

CREATE TABLE `CountryLanguage` (
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `Language` TEXT NOT NULL DEFAULT '',
  `IsOfficial`TEXT NOT NULL DEFAULT 'F',
  `Percentage` REAL NOT NULL DEFAULT 0.0,
  PRIMARY KEY (`CountryCode`,`Language`),
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

/* Answer the following: List down the cities that belong to the country with a life expectancy of 66.4. */
SELECT 
SELECT T2.Name FROM Country AS T1 INNER JOIN City AS T2 ON T1.Code = T2.CountryCode WHERE T1.LifeExpectancy = 66.4
/* Given the following database schema: */
CREATE TABLE sqlite_sequence(name,seq)

CREATE TABLE `City` (
  `ID` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
  `Name` TEXT NOT NULL DEFAULT '',
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `District` TEXT NOT NULL DEFAULT '',
  `Population` INTEGER NOT NULL DEFAULT 0,
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

CREATE TABLE `Country` (
  `Code` TEXT NOT NULL DEFAULT '',
  `Name` TEXT NOT NULL DEFAULT '',
  `Continent` TEXT NOT NULL DEFAULT 'Asia',
  `Region` TEXT NOT NULL DEFAULT '',
  `SurfaceArea` REAL NOT NULL DEFAULT 0.00,
  `IndepYear` INTEGER DEFAULT NULL,
  `Population` INTEGER NOT NULL DEFAULT 0,
  `LifeExpectancy` REAL DEFAULT NULL,
  `GNP` REAL DEFAULT NULL,
  `GNPOld` REAL DEFAULT NULL,
  `LocalName` TEXT NOT NULL DEFAULT '',
  `GovernmentForm` TEXT NOT NULL DEFAULT '',
  `HeadOfState` TEXT DEFAULT NULL,
  `Capital` INTEGER DEFAULT NULL,
  `Code2` TEXT NOT NULL DEFAULT '',
  PRIMARY KEY (`Code`)
)

CREATE TABLE `CountryLanguage` (
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `Language` TEXT NOT NULL DEFAULT '',
  `IsOfficial`TEXT NOT NULL DEFAULT 'F',
  `Percentage` REAL NOT NULL DEFAULT 0.0,
  PRIMARY KEY (`CountryCode`,`Language`),
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

/* Answer the following: Give the head of the state of the country with the lowest percentage use of English as their language. head of the state refers to HeadOfState; lowest percentage use of English as their language refers to MIN(Percentage WHERE `Language` = 'English'); */
SELECT 
SELECT T1.HeadOfState FROM Country AS T1 INNER JOIN CountryLanguage AS T2 ON T1.Code = T2.CountryCode WHERE T2.Language = 'English' ORDER BY T2.Percentage LIMIT 1
/* Given the following database schema: */
CREATE TABLE sqlite_sequence(name,seq)

CREATE TABLE `City` (
  `ID` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
  `Name` TEXT NOT NULL DEFAULT '',
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `District` TEXT NOT NULL DEFAULT '',
  `Population` INTEGER NOT NULL DEFAULT 0,
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

CREATE TABLE `Country` (
  `Code` TEXT NOT NULL DEFAULT '',
  `Name` TEXT NOT NULL DEFAULT '',
  `Continent` TEXT NOT NULL DEFAULT 'Asia',
  `Region` TEXT NOT NULL DEFAULT '',
  `SurfaceArea` REAL NOT NULL DEFAULT 0.00,
  `IndepYear` INTEGER DEFAULT NULL,
  `Population` INTEGER NOT NULL DEFAULT 0,
  `LifeExpectancy` REAL DEFAULT NULL,
  `GNP` REAL DEFAULT NULL,
  `GNPOld` REAL DEFAULT NULL,
  `LocalName` TEXT NOT NULL DEFAULT '',
  `GovernmentForm` TEXT NOT NULL DEFAULT '',
  `HeadOfState` TEXT DEFAULT NULL,
  `Capital` INTEGER DEFAULT NULL,
  `Code2` TEXT NOT NULL DEFAULT '',
  PRIMARY KEY (`Code`)
)

CREATE TABLE `CountryLanguage` (
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `Language` TEXT NOT NULL DEFAULT '',
  `IsOfficial`TEXT NOT NULL DEFAULT 'F',
  `Percentage` REAL NOT NULL DEFAULT 0.0,
  PRIMARY KEY (`CountryCode`,`Language`),
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

/* Answer the following: What is the surface area of the country where Sutton Coldfield city belongs? */
SELECT 
SELECT T1.SurfaceArea FROM Country AS T1 INNER JOIN City AS T2 ON T1.Code = T2.CountryCode WHERE T2.Name = 'Sutton Coldfield'
/* Given the following database schema: */
CREATE TABLE sqlite_sequence(name,seq)

CREATE TABLE `City` (
  `ID` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
  `Name` TEXT NOT NULL DEFAULT '',
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `District` TEXT NOT NULL DEFAULT '',
  `Population` INTEGER NOT NULL DEFAULT 0,
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

CREATE TABLE `Country` (
  `Code` TEXT NOT NULL DEFAULT '',
  `Name` TEXT NOT NULL DEFAULT '',
  `Continent` TEXT NOT NULL DEFAULT 'Asia',
  `Region` TEXT NOT NULL DEFAULT '',
  `SurfaceArea` REAL NOT NULL DEFAULT 0.00,
  `IndepYear` INTEGER DEFAULT NULL,
  `Population` INTEGER NOT NULL DEFAULT 0,
  `LifeExpectancy` REAL DEFAULT NULL,
  `GNP` REAL DEFAULT NULL,
  `GNPOld` REAL DEFAULT NULL,
  `LocalName` TEXT NOT NULL DEFAULT '',
  `GovernmentForm` TEXT NOT NULL DEFAULT '',
  `HeadOfState` TEXT DEFAULT NULL,
  `Capital` INTEGER DEFAULT NULL,
  `Code2` TEXT NOT NULL DEFAULT '',
  PRIMARY KEY (`Code`)
)

CREATE TABLE `CountryLanguage` (
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `Language` TEXT NOT NULL DEFAULT '',
  `IsOfficial`TEXT NOT NULL DEFAULT 'F',
  `Percentage` REAL NOT NULL DEFAULT 0.0,
  PRIMARY KEY (`CountryCode`,`Language`),
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

/* Answer the following: List down the languages of the countries that have population below 8000. population below 8000 refers to Population < 8000; */
SELECT 
SELECT T2.Language FROM Country AS T1 INNER JOIN CountryLanguage AS T2 ON T1.Code = T2.CountryCode WHERE T1.Population < 8000
/* Given the following database schema: */
CREATE TABLE sqlite_sequence(name,seq)

CREATE TABLE `City` (
  `ID` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
  `Name` TEXT NOT NULL DEFAULT '',
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `District` TEXT NOT NULL DEFAULT '',
  `Population` INTEGER NOT NULL DEFAULT 0,
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

CREATE TABLE `Country` (
  `Code` TEXT NOT NULL DEFAULT '',
  `Name` TEXT NOT NULL DEFAULT '',
  `Continent` TEXT NOT NULL DEFAULT 'Asia',
  `Region` TEXT NOT NULL DEFAULT '',
  `SurfaceArea` REAL NOT NULL DEFAULT 0.00,
  `IndepYear` INTEGER DEFAULT NULL,
  `Population` INTEGER NOT NULL DEFAULT 0,
  `LifeExpectancy` REAL DEFAULT NULL,
  `GNP` REAL DEFAULT NULL,
  `GNPOld` REAL DEFAULT NULL,
  `LocalName` TEXT NOT NULL DEFAULT '',
  `GovernmentForm` TEXT NOT NULL DEFAULT '',
  `HeadOfState` TEXT DEFAULT NULL,
  `Capital` INTEGER DEFAULT NULL,
  `Code2` TEXT NOT NULL DEFAULT '',
  PRIMARY KEY (`Code`)
)

CREATE TABLE `CountryLanguage` (
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `Language` TEXT NOT NULL DEFAULT '',
  `IsOfficial`TEXT NOT NULL DEFAULT 'F',
  `Percentage` REAL NOT NULL DEFAULT 0.0,
  PRIMARY KEY (`CountryCode`,`Language`),
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

/* Answer the following: What are the official languages used in Belgium? official languages refers to IsOfficial = 'T'; Belgium is a name of country; */
SELECT 
SELECT T2.Language FROM Country AS T1 INNER JOIN CountryLanguage AS T2 ON T1.Code = T2.CountryCode WHERE T1.Name = 'Belgium' AND T2.IsOfficial = 'T'
/* Given the following database schema: */
CREATE TABLE sqlite_sequence(name,seq)

CREATE TABLE `City` (
  `ID` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
  `Name` TEXT NOT NULL DEFAULT '',
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `District` TEXT NOT NULL DEFAULT '',
  `Population` INTEGER NOT NULL DEFAULT 0,
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

CREATE TABLE `Country` (
  `Code` TEXT NOT NULL DEFAULT '',
  `Name` TEXT NOT NULL DEFAULT '',
  `Continent` TEXT NOT NULL DEFAULT 'Asia',
  `Region` TEXT NOT NULL DEFAULT '',
  `SurfaceArea` REAL NOT NULL DEFAULT 0.00,
  `IndepYear` INTEGER DEFAULT NULL,
  `Population` INTEGER NOT NULL DEFAULT 0,
  `LifeExpectancy` REAL DEFAULT NULL,
  `GNP` REAL DEFAULT NULL,
  `GNPOld` REAL DEFAULT NULL,
  `LocalName` TEXT NOT NULL DEFAULT '',
  `GovernmentForm` TEXT NOT NULL DEFAULT '',
  `HeadOfState` TEXT DEFAULT NULL,
  `Capital` INTEGER DEFAULT NULL,
  `Code2` TEXT NOT NULL DEFAULT '',
  PRIMARY KEY (`Code`)
)

CREATE TABLE `CountryLanguage` (
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `Language` TEXT NOT NULL DEFAULT '',
  `IsOfficial`TEXT NOT NULL DEFAULT 'F',
  `Percentage` REAL NOT NULL DEFAULT 0.0,
  PRIMARY KEY (`CountryCode`,`Language`),
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

/* Answer the following: Give the cities and district names that belong to the country with Hajastan as its local name. */
SELECT 
SELECT T2.Name, T2.District FROM Country AS T1 INNER JOIN City AS T2 ON T1.Code = T2.CountryCode WHERE T1.LocalName = 'Hajastan'
/* Given the following database schema: */
CREATE TABLE sqlite_sequence(name,seq)

CREATE TABLE `City` (
  `ID` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
  `Name` TEXT NOT NULL DEFAULT '',
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `District` TEXT NOT NULL DEFAULT '',
  `Population` INTEGER NOT NULL DEFAULT 0,
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

CREATE TABLE `Country` (
  `Code` TEXT NOT NULL DEFAULT '',
  `Name` TEXT NOT NULL DEFAULT '',
  `Continent` TEXT NOT NULL DEFAULT 'Asia',
  `Region` TEXT NOT NULL DEFAULT '',
  `SurfaceArea` REAL NOT NULL DEFAULT 0.00,
  `IndepYear` INTEGER DEFAULT NULL,
  `Population` INTEGER NOT NULL DEFAULT 0,
  `LifeExpectancy` REAL DEFAULT NULL,
  `GNP` REAL DEFAULT NULL,
  `GNPOld` REAL DEFAULT NULL,
  `LocalName` TEXT NOT NULL DEFAULT '',
  `GovernmentForm` TEXT NOT NULL DEFAULT '',
  `HeadOfState` TEXT DEFAULT NULL,
  `Capital` INTEGER DEFAULT NULL,
  `Code2` TEXT NOT NULL DEFAULT '',
  PRIMARY KEY (`Code`)
)

CREATE TABLE `CountryLanguage` (
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `Language` TEXT NOT NULL DEFAULT '',
  `IsOfficial`TEXT NOT NULL DEFAULT 'F',
  `Percentage` REAL NOT NULL DEFAULT 0.0,
  PRIMARY KEY (`CountryCode`,`Language`),
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

/* Answer the following: How many languages are used in Cyprus? Cyprus is a name of Country; */
SELECT 
SELECT SUM(CASE WHEN T1.Name = 'Cyprus' THEN 1 ELSE 0 END) FROM Country AS T1 INNER JOIN CountryLanguage AS T2 ON T1.Code = T2.CountryCode
/* Given the following database schema: */
CREATE TABLE sqlite_sequence(name,seq)

CREATE TABLE `City` (
  `ID` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
  `Name` TEXT NOT NULL DEFAULT '',
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `District` TEXT NOT NULL DEFAULT '',
  `Population` INTEGER NOT NULL DEFAULT 0,
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

CREATE TABLE `Country` (
  `Code` TEXT NOT NULL DEFAULT '',
  `Name` TEXT NOT NULL DEFAULT '',
  `Continent` TEXT NOT NULL DEFAULT 'Asia',
  `Region` TEXT NOT NULL DEFAULT '',
  `SurfaceArea` REAL NOT NULL DEFAULT 0.00,
  `IndepYear` INTEGER DEFAULT NULL,
  `Population` INTEGER NOT NULL DEFAULT 0,
  `LifeExpectancy` REAL DEFAULT NULL,
  `GNP` REAL DEFAULT NULL,
  `GNPOld` REAL DEFAULT NULL,
  `LocalName` TEXT NOT NULL DEFAULT '',
  `GovernmentForm` TEXT NOT NULL DEFAULT '',
  `HeadOfState` TEXT DEFAULT NULL,
  `Capital` INTEGER DEFAULT NULL,
  `Code2` TEXT NOT NULL DEFAULT '',
  PRIMARY KEY (`Code`)
)

CREATE TABLE `CountryLanguage` (
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `Language` TEXT NOT NULL DEFAULT '',
  `IsOfficial`TEXT NOT NULL DEFAULT 'F',
  `Percentage` REAL NOT NULL DEFAULT 0.0,
  PRIMARY KEY (`CountryCode`,`Language`),
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

/* Answer the following: Provide the language used by the people of Belize. Belize is a name of country; */
SELECT 
SELECT T2.Language FROM Country AS T1 INNER JOIN CountryLanguage AS T2 ON T1.Code = T2.CountryCode WHERE T1.Name = 'Belize'
/* Given the following database schema: */
CREATE TABLE sqlite_sequence(name,seq)

CREATE TABLE `City` (
  `ID` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
  `Name` TEXT NOT NULL DEFAULT '',
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `District` TEXT NOT NULL DEFAULT '',
  `Population` INTEGER NOT NULL DEFAULT 0,
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

CREATE TABLE `Country` (
  `Code` TEXT NOT NULL DEFAULT '',
  `Name` TEXT NOT NULL DEFAULT '',
  `Continent` TEXT NOT NULL DEFAULT 'Asia',
  `Region` TEXT NOT NULL DEFAULT '',
  `SurfaceArea` REAL NOT NULL DEFAULT 0.00,
  `IndepYear` INTEGER DEFAULT NULL,
  `Population` INTEGER NOT NULL DEFAULT 0,
  `LifeExpectancy` REAL DEFAULT NULL,
  `GNP` REAL DEFAULT NULL,
  `GNPOld` REAL DEFAULT NULL,
  `LocalName` TEXT NOT NULL DEFAULT '',
  `GovernmentForm` TEXT NOT NULL DEFAULT '',
  `HeadOfState` TEXT DEFAULT NULL,
  `Capital` INTEGER DEFAULT NULL,
  `Code2` TEXT NOT NULL DEFAULT '',
  PRIMARY KEY (`Code`)
)

CREATE TABLE `CountryLanguage` (
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `Language` TEXT NOT NULL DEFAULT '',
  `IsOfficial`TEXT NOT NULL DEFAULT 'F',
  `Percentage` REAL NOT NULL DEFAULT 0.0,
  PRIMARY KEY (`CountryCode`,`Language`),
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

/* Answer the following: List down the districts belong to the country headed by Adolf Ogi. headed by Adolf Ogi refers to HeadOfState = 'Adolf Ogi'; */
SELECT 
SELECT T2.District FROM Country AS T1 INNER JOIN City AS T2 ON T1.Code = T2.CountryCode WHERE T1.HeadOfState = 'Adolf Ogi'
/* Given the following database schema: */
CREATE TABLE sqlite_sequence(name,seq)

CREATE TABLE `City` (
  `ID` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
  `Name` TEXT NOT NULL DEFAULT '',
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `District` TEXT NOT NULL DEFAULT '',
  `Population` INTEGER NOT NULL DEFAULT 0,
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

CREATE TABLE `Country` (
  `Code` TEXT NOT NULL DEFAULT '',
  `Name` TEXT NOT NULL DEFAULT '',
  `Continent` TEXT NOT NULL DEFAULT 'Asia',
  `Region` TEXT NOT NULL DEFAULT '',
  `SurfaceArea` REAL NOT NULL DEFAULT 0.00,
  `IndepYear` INTEGER DEFAULT NULL,
  `Population` INTEGER NOT NULL DEFAULT 0,
  `LifeExpectancy` REAL DEFAULT NULL,
  `GNP` REAL DEFAULT NULL,
  `GNPOld` REAL DEFAULT NULL,
  `LocalName` TEXT NOT NULL DEFAULT '',
  `GovernmentForm` TEXT NOT NULL DEFAULT '',
  `HeadOfState` TEXT DEFAULT NULL,
  `Capital` INTEGER DEFAULT NULL,
  `Code2` TEXT NOT NULL DEFAULT '',
  PRIMARY KEY (`Code`)
)

CREATE TABLE `CountryLanguage` (
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `Language` TEXT NOT NULL DEFAULT '',
  `IsOfficial`TEXT NOT NULL DEFAULT 'F',
  `Percentage` REAL NOT NULL DEFAULT 0.0,
  PRIMARY KEY (`CountryCode`,`Language`),
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

/* Answer the following: Who is the head of the country where Santa Catarina district belongs? head of the country refers to HeadOfState; */
SELECT 
SELECT T1.HeadOfState FROM Country AS T1 INNER JOIN City AS T2 ON T1.Code = T2.CountryCode WHERE T2.District = 'Santa Catarina'
/* Given the following database schema: */
CREATE TABLE sqlite_sequence(name,seq)

CREATE TABLE `City` (
  `ID` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
  `Name` TEXT NOT NULL DEFAULT '',
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `District` TEXT NOT NULL DEFAULT '',
  `Population` INTEGER NOT NULL DEFAULT 0,
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

CREATE TABLE `Country` (
  `Code` TEXT NOT NULL DEFAULT '',
  `Name` TEXT NOT NULL DEFAULT '',
  `Continent` TEXT NOT NULL DEFAULT 'Asia',
  `Region` TEXT NOT NULL DEFAULT '',
  `SurfaceArea` REAL NOT NULL DEFAULT 0.00,
  `IndepYear` INTEGER DEFAULT NULL,
  `Population` INTEGER NOT NULL DEFAULT 0,
  `LifeExpectancy` REAL DEFAULT NULL,
  `GNP` REAL DEFAULT NULL,
  `GNPOld` REAL DEFAULT NULL,
  `LocalName` TEXT NOT NULL DEFAULT '',
  `GovernmentForm` TEXT NOT NULL DEFAULT '',
  `HeadOfState` TEXT DEFAULT NULL,
  `Capital` INTEGER DEFAULT NULL,
  `Code2` TEXT NOT NULL DEFAULT '',
  PRIMARY KEY (`Code`)
)

CREATE TABLE `CountryLanguage` (
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `Language` TEXT NOT NULL DEFAULT '',
  `IsOfficial`TEXT NOT NULL DEFAULT 'F',
  `Percentage` REAL NOT NULL DEFAULT 0.0,
  PRIMARY KEY (`CountryCode`,`Language`),
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

/* Answer the following: Among the countries that have GNP greater than 1500, what is the percentage of the countries have English as its language? GNP greater than 1500 refers to GNP > 1500 ; percentage = MULTIPLY(DIVIDE(SUM(Code WHERE GNP > 1500 AND Language = 'English'), COUNT(Code WHERE GNP > 1500)) 1.0); English as its language refers to Language = 'English'; */
SELECT 
SELECT CAST(SUM(IIF(T2.Language = 'English', 1, 0)) AS REAL) * 100 / COUNT(T1.Code) FROM Country AS T1 INNER JOIN CountryLanguage AS T2 ON T1.Code = T2.CountryCode WHERE T1.GNP > 1500
/* Given the following database schema: */
CREATE TABLE sqlite_sequence(name,seq)

CREATE TABLE `City` (
  `ID` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
  `Name` TEXT NOT NULL DEFAULT '',
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `District` TEXT NOT NULL DEFAULT '',
  `Population` INTEGER NOT NULL DEFAULT 0,
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

CREATE TABLE `Country` (
  `Code` TEXT NOT NULL DEFAULT '',
  `Name` TEXT NOT NULL DEFAULT '',
  `Continent` TEXT NOT NULL DEFAULT 'Asia',
  `Region` TEXT NOT NULL DEFAULT '',
  `SurfaceArea` REAL NOT NULL DEFAULT 0.00,
  `IndepYear` INTEGER DEFAULT NULL,
  `Population` INTEGER NOT NULL DEFAULT 0,
  `LifeExpectancy` REAL DEFAULT NULL,
  `GNP` REAL DEFAULT NULL,
  `GNPOld` REAL DEFAULT NULL,
  `LocalName` TEXT NOT NULL DEFAULT '',
  `GovernmentForm` TEXT NOT NULL DEFAULT '',
  `HeadOfState` TEXT DEFAULT NULL,
  `Capital` INTEGER DEFAULT NULL,
  `Code2` TEXT NOT NULL DEFAULT '',
  PRIMARY KEY (`Code`)
)

CREATE TABLE `CountryLanguage` (
  `CountryCode` TEXT NOT NULL DEFAULT '',
  `Language` TEXT NOT NULL DEFAULT '',
  `IsOfficial`TEXT NOT NULL DEFAULT 'F',
  `Percentage` REAL NOT NULL DEFAULT 0.0,
  PRIMARY KEY (`CountryCode`,`Language`),
  FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
)

/* Answer the following: In English speaking countries, provide the difference between the number of countries with republic and constitutional monarchy as its government form. English speaking refers to Language = 'English' ; difference = SUBTRACT(COUNT(Language = 'English' WHERE GovernmentForm = 'Republic'), COUNT(Language = 'English' WHERE GovernmentForm = 'ConstitutionalMonarchy')); */
SELECT 
SELECT COUNT(T1.GovernmentForm = 'Republic') - COUNT(T1.GovernmentForm = 'ConstitutionalMonarchy') FROM Country AS T1 INNER JOIN CountryLanguage AS T2 ON T1.Code = T2.CountryCode WHERE T2.Language = 'English'