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: What country declared its independence in 1994? declared independence in 1994 refers to IndepYear = 1994; */
SELECT 
SELECT Name FROM Country WHERE IndepYear = 1994
/* 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 all the countries in Asia. Asia refers to Continent = 'Asia'; */
SELECT 
SELECT Name FROM Country WHERE Continent = 'Asia'
/* 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 country in Asia has the largest gross national product(GNP)? Asia refers to Continent = 'Asia'; largest gross national product refers to MAX(GNP); */
SELECT 
SELECT Name FROM Country WHERE Continent = 'Asia' ORDER BY GNP 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: How many cities are in the Philippines? Philippines refers to CountryCode = 'PHL'; */
SELECT 
SELECT COUNT(ID) FROM City WHERE Name = 'PHL'
/* 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 local name of Ukraine that they are also known for? Ukraine is a name of country; */
SELECT 
SELECT LocalName FROM Country WHERE Name = 'Ukraine'
/* 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 have Socialistic Republic form of government? Socialistic Republic form of government refers to GovernmentForm = 'Socialistic Republic'; */
SELECT 
SELECT COUNT(Code) FROM Country WHERE GovernmentForm = 'Socialistic Republic'
/* 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 official language of China? official language refers to IsOfficial = 'T'; China 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 = 'China' 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: How many percent of the population of China used Chinese as their language? percent refers to Percentage; China is a name of country; use Chinese as their language refers to Language = 'Chinese'; */
SELECT 
SELECT T2.Percentage FROM Country AS T1 INNER JOIN CountryLanguage AS T2 ON T1.Code = T2.CountryCode WHERE T1.Name = 'China' AND T2.Language = 'Chinese'
/* 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 form of government that the city of Manila has? form of government refers to GovernmentForm; */
SELECT 
SELECT T1.GovernmentForm FROM Country AS T1 INNER JOIN City AS T2 ON T1.Code = T2.CountryCode WHERE T2.Name = 'Manila'
/* 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 of the Philippines? capital city refers to Capital; Philippines is a name of country; */
SELECT 
SELECT T1.Capital FROM Country AS T1 INNER JOIN City AS T2 ON T1.Code = T2.CountryCode WHERE T1.Name = 'Philipiines'
/* 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 all the languages used in Europe. Europe refers to Continent = 'Europe'; */
SELECT 
SELECT T2.Language FROM Country AS T1 INNER JOIN CountryLanguage AS T2 ON T1.Code = T2.CountryCode WHERE T1.Continent = 'Europe'
/* 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 state of the country where the city of Pyongyang is under? */
SELECT 
SELECT T1.HeadOfState FROM Country AS T1 INNER JOIN City AS T2 ON T1.Code = T2.CountryCode WHERE T2.Name = 'Pyongyang'
/* 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 unofficial languages are used in Italy? unofficial languages refers to IsOfficial = 'F'; Italy is a name of country; */
SELECT 
SELECT SUM(CASE WHEN T2.IsOfficial = 'F' THEN 1 ELSE 0 END) FROM Country AS T1 INNER JOIN CountryLanguage AS T2 ON T1.Code = T2.CountryCode WHERE T1.Name = 'Italy'
/* 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 city in Russia has the least population? Russia is a name of country; least population refers to MIN(Population); */
SELECT 
SELECT T2.Name FROM Country AS T1 INNER JOIN City AS T2 ON T1.Code = T2.CountryCode WHERE T1.Name = 'Russian Federation' ORDER BY T2.Population ASC 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 all the cities in the country where there is high life expectancy at birth. high life expectancy at birth refers to MAX(LifeExpectancy); */
SELECT 
SELECT T2.Name FROM Country AS T1 INNER JOIN City AS T2 ON T1.Code = T2.CountryCode 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 all the official and unofficial languages used by the country that declared its independence in 1830. official language refers to IsOfficial = 'T'; unofficial language refers to IsOfficial = 'F'; declared independence in 1830 refers to IndepYear = 1830; */
SELECT 
SELECT T2.Language, T2.IsOfficial FROM Country AS T1 INNER JOIN CountryLanguage AS T2 ON T1.Code = T2.CountryCode WHERE T1.IndepYear = 1830 GROUP BY T2.Language, T2.IsOfficial
/* 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 of the country with largest population? capital city refers to Capital; largest population refers to MAX(Population); */
SELECT 
SELECT T1.Capital FROM Country AS T1 INNER JOIN City AS T2 ON T1.Code = T2.CountryCode ORDER BY T1.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: List all the countries in the continent of Asia that use English as their unofficial language. use English as unofficial language refers to Language = 'English' WHERE IsOfficial = 'F'; */
SELECT 
SELECT T1.Name FROM Country AS T1 INNER JOIN CountryLanguage AS T2 ON T1.Code = T2.CountryCode WHERE T1.Continent = 'Asia' AND T2.IsOfficial = 'F' GROUP BY T1.Name
/* 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: Calculate the average GNP of all countries that use Arabic language. average GNP = AVG(GNP); use Arabic language refers to Language = 'Arabic'; */
SELECT 
SELECT AVG(T1.GNP) FROM Country AS T1 INNER JOIN CountryLanguage AS T2 ON T1.Code = T2.CountryCode WHERE T2.Language = 'Arabic'
/* 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: Calculate the percentage of the surface area of all countries that uses Chinese as one of their languages. percentage = DIVIDE(MULTIPLY(SUM(SurfaceArea WHERE Language = 'Chinese'), SUM(SurfaceArea)), 1.0); Chinese as one of the languages refers to Language = 'Chinese'; */
SELECT 
SELECT CAST(SUM(IIF(T2.Language = 'Chinese', T1.SurfaceArea, 0)) AS REAL) * 100 / SUM(T1.SurfaceArea) 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: Which country has the smallest surface area? smallest surface area refers to MIN(smallest surface area); */
SELECT 
SELECT Name FROM Country ORDER BY SurfaceArea ASC 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: Write down the name of the largest population country. largest population refers to MAX(Population); */
SELECT 
SELECT Name FROM Country ORDER BY 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: What is the language of the smallest population country? smallest population refers to MIN(Population); */
SELECT 
SELECT T2.Language FROM Country AS T1 INNER JOIN CountryLanguage AS T2 ON T1.Code = T2.CountryCode ORDER BY T1.Population ASC 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 name of countries whereby English is their official language. English is the official language refers to Language = 'English' AND IsOfficial = 'T'; */
SELECT 
SELECT T1.Name FROM Country AS T1 INNER JOIN CountryLanguage AS T2 ON T1.Code = T2.CountryCode WHERE T2.Language = 'English' 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: List down the official language of the countries which declared independence after 1990, official lanaguage refers to IsOfficial = 'T'; declared independence after 1990 refers to IndepYear > 1990; */
SELECT 
SELECT T1.Name, T2.Language FROM Country AS T1 INNER JOIN CountryLanguage AS T2 ON T1.Code = T2.CountryCode WHERE T1.IndepYear > 1990 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: What is the percentage of English used in Australia? English refers to Language = 'English'; Australia is a name of country; */
SELECT 
SELECT T2.Percentage FROM Country AS T1 INNER JOIN CountryLanguage AS T2 ON T1.Code = T2.CountryCode WHERE T1.Name = 'Australia' AND T2.Language = 'English'
/* 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 languages used in Malaysia. Malaysia 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 = 'Malaysia'
/* 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: Which country has the most crowded city in the world? most crowded city refers to MAX(Population); */
SELECT 
SELECT T1.Name 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: What is the life expectancy of residents in the most crowded city? most crowded city refers to MAX(Population); */
SELECT 
SELECT T2.LifeExpectancy FROM City AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.Code ORDER BY T1.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: What is the GNP of the least crowded city in the world? least crowded city refers to MIN(Population); */
SELECT 
SELECT T2.GNP FROM City AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.Code ORDER BY T1.Population ASC 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: Within the 5 most crowded cities in the world, which country has the most languages used? most crowded cities refers to MAX(Population); has the most languages used refers to MAX(COUNT(Language)); */
SELECT 
SELECT Name FROM ( SELECT T1.Name, T2.Language FROM City AS T1 INNER JOIN CountryLanguage AS T2 ON T1.CountryCode = T2.CountryCode GROUP BY T1.Name, T1.Population, T2.Language ORDER BY T1.Population DESC ) AS T3 GROUP BY t3.Name ORDER BY COUNT(Language) DESC LIMIT 1