Database schema:

CREATE TABLE "Country" (
	"CountryCode" TEXT NOT NULL -- example: ['ABW', 'ADO'],
	"ShortName" TEXT -- example: ['Albania', 'Afghanistan'],
	"TableName" TEXT -- example: ['Albania', 'Afghanistan'],
	"LongName" TEXT -- example: ['Islamic State of Afghanistan', 'Republic of Albania'],
	"Alpha2Code" TEXT -- example: ['AL', 'AF'],
	"CurrencyUnit" TEXT -- example: ['Albanian lek', 'Afghan afghani'],
	"SpecialNotes" TEXT -- example: ['', 'Fiscal year end: March 20; reporting period for na'],
	"Region" TEXT -- example: ['Europe & Central Asia', 'South Asia'],
	"IncomeGroup" TEXT -- example: ['Low income', 'Upper middle income'],
	"Wb2Code" TEXT -- example: ['AL', 'AF'],
	"NationalAccountsBaseYear" TEXT -- example: ['2002/03', 'Original chained constant price data are rescaled.'],
	"NationalAccountsReferenceYear" TEXT -- example: ['', '1996'],
	"SnaPriceValuation" TEXT -- example: ['', 'Value added at basic prices (VAB)'],
	"LendingCategory" TEXT -- example: ['IBRD', 'IDA'],
	"OtherGroups" TEXT -- example: ['', 'HIPC'],
	"SystemOfNationalAccounts" TEXT -- example: ['Country uses the 1993 System of National Accounts ', 'Country uses the 1968 System of National Accounts '],
	"AlternativeConversionFactor" TEXT, 
	"PppSurveyYear" TEXT -- example: ['', 'Rolling'],
	"BalanceOfPaymentsManualInUse" TEXT -- example: ['', 'IMF Balance of Payments Manual, 6th edition.'],
	"ExternalDebtReportingStatus" TEXT -- example: ['Actual', ''],
	"SystemOfTrade" TEXT -- example: ['Special trade system', 'General trade system'],
	"GovernmentAccountingConcept" TEXT -- example: ['Consolidated central government', 'Budgetary central government'],
	"ImfDataDisseminationStandard" TEXT -- example: ['', 'General Data Dissemination System (GDDS)'],
	"LatestPopulationCensus" TEXT -- example: ['1979', '2011'],
	"LatestHouseholdSurvey" TEXT -- example: ['Multiple Indicator Cluster Survey (MICS), 2010/11', 'Demographic and Health Survey (DHS), 2008/09'],
	"SourceOfMostRecentIncomeAndExpenditureData" TEXT -- example: ['Living Standards Measurement Study Survey (LSMS), ', 'Integrated household survey (IHS), 2008'],
	"VitalRegistrationComplete" TEXT -- example: ['', 'Yes'],
	"LatestAgriculturalCensus" TEXT -- example: ['2012', '2013/14'],
	"LatestIndustrialData" INTEGER -- example: ['2010', '2011'],
	"LatestTradeData" INTEGER -- example: ['2013', '2006'],
	"LatestWaterWithdrawalData" INTEGER -- example: ['2000', '2006'],
	PRIMARY KEY ("CountryCode")
)


CREATE TABLE "CountryNotes" (
	"Countrycode" TEXT NOT NULL -- example: ['ABW', 'ADO'],
	"Seriescode" TEXT NOT NULL -- example: ['EG.ELC.RNEW.ZS', 'EG.EGY.PRIM.PP.KD'],
	"Description" TEXT -- example: ['Sources: Estimated based on UN Energy Statistics (', 'Sources: UN Energy Statistics (2014)'],
	PRIMARY KEY ("Countrycode", "Seriescode"), 
	CONSTRAINT fk_countrynotes_series FOREIGN KEY("Seriescode") REFERENCES "Series" ("SeriesCode"),
	CONSTRAINT fk_countrynotes_country FOREIGN KEY("Countrycode") REFERENCES "Country" ("CountryCode")
)


CREATE TABLE "Footnotes" (
	"Countrycode" TEXT NOT NULL -- example: ['ABW', 'ADO'],
	"Seriescode" TEXT NOT NULL -- example: ['BX.KLT.DINV.CD.WD', 'AG.LND.FRST.K2'],
	"Year" TEXT -- example: ['YR1990', 'YR2000'],
	"Description" TEXT -- example: ['Not specified', 'Source: United Nations Conference on Trade and Dev'],
	PRIMARY KEY ("Countrycode", "Seriescode", "Year"), 
	CONSTRAINT fk_footnotes_series FOREIGN KEY("Seriescode") REFERENCES "Series" ("SeriesCode"),
	CONSTRAINT fk_footnotes_country FOREIGN KEY("Countrycode") REFERENCES "Country" ("CountryCode")
)


CREATE TABLE "Indicators" (
	"CountryName" TEXT -- example: ['Caribbean small states', 'Arab World'],
	"CountryCode" TEXT NOT NULL -- example: ['ABW', 'ADO'],
	"IndicatorName" TEXT -- example: ['Adolescent fertility rate (births per 1,000 women ', 'Age dependency ratio (% of working-age population)'],
	"IndicatorCode" TEXT NOT NULL -- example: ['AG.LND.AGRI.ZS', 'AG.LND.AGRI.K2'],
	"Year" INTEGER NOT NULL -- example: ['1961', '1962'],
	"Value" INTEGER -- example: ['87', '133'],
	PRIMARY KEY ("CountryCode", "IndicatorCode", "Year"), 
	CONSTRAINT fk_indicators_country FOREIGN KEY("CountryCode") REFERENCES "Country" ("CountryCode")
)


CREATE TABLE "Series" (
	"SeriesCode" TEXT NOT NULL -- example: ['AG.AGR.TRAC.NO', 'AG.CON.FERT.PT.ZS'],
	"Topic" TEXT -- example: ['Economic Policy & Debt: Balance of payments: Capit', 'Economic Policy & Debt: Balance of payments: Curre'],
	"IndicatorName" TEXT -- example: ['Foreign direct investment, net inflows (% of GDP)', 'Foreign direct investment, net (BoP, current US$)'],
	"ShortDefinition" TEXT -- example: ['', 'Total external debt is debt owed to nonresidents r'],
	"LongDefinition" TEXT -- example: ['Foreign direct investment refers to direct investm', 'Foreign direct investment are the net inflows of i'],
	"UnitOfMeasure" TEXT -- example: ['', '`'],
	"Periodicity" TEXT -- example: ['Annual'],
	"BasePeriod" TEXT -- example: ['', '2005'],
	"OtherNotes" INTEGER, 
	"AggregationMethod" TEXT -- example: ['', 'Weighted average'],
	"LimitationsAndExceptions" TEXT -- example: ['', 'FDI data do not give a complete picture of interna'],
	"NotesFromOriginalSource" TEXT -- example: ['', 'Estimates are presented with uncertainty intervals'],
	"GeneralComments" TEXT -- example: ['Note: Data starting from 2005 are based on the six', 'Note: Data are based on the sixth edition of the I'],
	"Source" TEXT -- example: ['International Monetary Fund, International Financi', 'International Monetary Fund, Balance of Payments S'],
	"StatisticalConceptAndMethodology" TEXT -- example: ['', 'Data on equity flows are based on balance of payme'],
	"DevelopmentRelevance" TEXT -- example: ['', 'Private financial flows - equity and debt - accoun'],
	"RelatedSourceLinks" TEXT -- example: ['', 'World Bank, PovcalNet: an online poverty analysis '],
	"OtherWebLinks" INTEGER, 
	"RelatedIndicators" INTEGER, 
	"LicenseType" TEXT -- example: ['Restricted', 'Open'],
	PRIMARY KEY ("SeriesCode")
)


CREATE TABLE "SeriesNotes" (
	"Seriescode" TEXT NOT NULL -- example: ['DT.DOD.PVLX.CD', 'IC.CUS.DURS.EX'],
	"Year" TEXT NOT NULL -- example: ['YR2002', 'YR2014'],
	"Description" TEXT -- example: ['Interpolated using data for 1957 and 1962.', 'Interpolated using data for 1957 and 1962, if the '],
	PRIMARY KEY ("Seriescode", "Year"), 
	CONSTRAINT fk_seriesnotes_series FOREIGN KEY("Seriescode") REFERENCES "Series" ("SeriesCode")
)

Question: Which upper middle income country has the lowest value of CO2 emissions (kt)?
Evidence: IncomeGroup = 'Upper middle income'; IndicatorName = 'CO2 emissions (kt); the lowest value refers to MIN(Value);

SQL:
SELECT T1.CountryCode FROM Country AS T1 INNER JOIN Indicators AS T2 ON T1.CountryCode = T2.CountryCode WHERE T1.IncomeGroup = 'Upper middle income' AND T2.IndicatorName = 'CO2 emissions (kt)' ORDER BY T2.Value ASC LIMIT 1