lianghsun/bird-text2sql-bench huggingface dataset:
### 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`)
)

### Question
What is the surface area and GNP of the country where Namibe district belongs?

### SQL
SELECT T2.SurfaceArea, T2.GNP FROM City AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.Code WHERE T1.District = 'Namibe'
### 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`)
)

### Question
List the names of the country that officially uses English as their language.

### Hint
officially uses English as their language refers to `Language` = 'English' AND IsOfficial = 'T';

### SQL
SELECT T2.Name FROM CountryLanguage AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.Code WHERE T1.IsOfficial = 'T' AND T1.Language = 'English'
### 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`)
)

### Question
What are the districts that belong to the country with the lowest surface area?

### Hint
lowest surface area refers to MIN(SurfaceArea);

### SQL
SELECT T1.District FROM City AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.Code ORDER BY T2.SurfaceArea ASC LIMIT 1
### 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`)
)

### Question
List down the country names of countries that have a GNP lower than 1000 and have Dutch as their language.

### Hint
GNP lower than 1000 refers to GNP < 1000; Dutch as their language refers to `Language` = 'Dutch';

### SQL
SELECT T2.Name FROM CountryLanguage AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.Code WHERE T2.GNP < 1000 AND T1.IsOfficial = 'T' AND T1.Language = 'Dutch'
### 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`)
)

### Question
What is the GNP of the country where district "Entre Rios" belongs?

### SQL
SELECT T2.GNP FROM City AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.Code WHERE T1.District = 'Entre Rios' LIMIT 1
### 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`)
)

### Question
What is the local name of the country where "The Valley" city belongs?

### SQL
SELECT T2.LocalName FROM City AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.Code WHERE T1.Name = 'The Valley'
### 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`)
)

### Question
List down the cities belongs to the country that has surface area greater than 7000000.

### Hint
surface area greater than 7000000 refers to SurfaceArea > 7000000;

### SQL
SELECT T2.Name, T1.Name FROM City AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.Code WHERE T2.SurfaceArea > 7000000
### 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`)
)

### Question
What is the life expectancy of the countries that uses Japanese as their language?

### Hint
uses Japanese as their language refers to `Language` = 'Japanese';

### SQL
SELECT AVG(T2.LifeExpectancy) FROM CountryLanguage AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.Code WHERE T1.Language = 'Japanese'
### 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`)
)

### Question
How many cities are there in the country with the surface area of 652090?

### SQL
SELECT T2.Name, COUNT(T1.Name) FROM City AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.Code WHERE T2.SurfaceArea = 652090 GROUP BY T2.Name
### 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`)
)

### Question
List down the languages of countries with an independence year between 1980 to 1995.

### Hint
independence year between 1980 to 1995 refers to IndepYear BETWEEN 1980 AND 1995;

### SQL
SELECT T2.Name, T1.Language FROM CountryLanguage AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.Code WHERE T2.IndepYear BETWEEN 1980 AND 1995
### 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`)
)

### Question
What is the life expectancy of the people living in Calama city?

### SQL
SELECT T2.LifeExpectancy FROM City AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.Code WHERE T1.Name = 'Calama'
### 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`)
)

### Question
Provide the language used in the country ruled by Pierre Buyoya.

### Hint
ruled by Pierre Buyoya refers to HeadOfState = 'Pierre Buyoya';

### SQL
SELECT T1.Language FROM CountryLanguage AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.Code WHERE T2.HeadOfState = 'Pierre Buyoya'
### 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`)
)

### Question
In countries with constitutional monarchy, what is the percentage of cities located in the district of England?

### Hint
constitutional monarchy refers to GovernmentForm = 'Constitutional Monarchy'; percentage = MULTIPLY(DIVIDE(SUM(GovernmentForm = 'Constitutional Monarchy' WHERE District = 'England'), COUNT(GovernmentForm = 'Constitutional Monarchy')), 100)

### SQL
SELECT CAST(SUM(CASE WHEN T1.District = 'England' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM City AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.Code WHERE T2.GovernmentForm = 'Constitutional Monarchy'
### 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`)
)

### Question
Among the cities with a population between 140000 and 150000, list the country that has life expectancy greater than 80% life expectancy of all countries.

### Hint
life expectancy greater than 80% life expectancy of all countries refers to LifeExpectancy < (MULTIPLY(AVG(LifeExpectancy), 0.8));

### SQL
SELECT T2.Name FROM City AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.Code WHERE T1.Population BETWEEN 140000 AND 150000 GROUP BY T2.Name, LifeExpectancy HAVING LifeExpectancy < ( SELECT AVG(LifeExpectancy) FROM Country ) * 0.8
### 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`)
)

### Question
Among the countries that use Italian as their language, what is the percentage of republic countries?

### Hint
use Italian as their language refers to `Language` = 'Italian'; percentage = MULTIPLY(DIVIDE(SUM(`Language` = 'Italian' WHERE GovernmentForm = 'Republic'), COUNT(`Language` = 'Italian')), 100); use Italian as their language refers to `Language` = 'Italian'; republic countries refers to GovernmentForm = 'Republic';

### SQL
SELECT CAST(SUM(CASE WHEN T2.GovernmentForm = 'Republic' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM CountryLanguage AS T1 INNER JOIN Country AS T2 ON T1.CountryCode = T2.Code WHERE T1.Language = 'Italian'