Database schema:

CREATE TABLE "Customers" (
	"CustomerID" INTEGER -- example: ['2', '1'],
	"Customer Names" TEXT -- example: ['WakeFern ', 'Avon Corp'],
	PRIMARY KEY ("CustomerID")
)


CREATE TABLE "Products" (
	"ProductID" INTEGER -- example: ['2', '1'],
	"Product Name" TEXT -- example: ['Cookware', 'Photo Frames'],
	PRIMARY KEY ("ProductID")
)


CREATE TABLE "Regions" (
	"StateCode" TEXT -- example: ['AL', 'AR'],
	"State" TEXT -- example: ['Arkansas', 'Alabama'],
	"Region" TEXT -- example: ['West', 'South'],
	PRIMARY KEY ("StateCode")
)


CREATE TABLE "Sales Orders" (
	"OrderNumber" TEXT -- example: ['SO - 0001001', 'SO - 0001000'],
	"Sales Channel" TEXT -- example: ['Online', 'In-Store'],
	"WarehouseCode" TEXT -- example: ['WARE-UHY1004', 'WARE-NMK1003'],
	"ProcuredDate" TEXT -- example: ['4/10/18', '12/31/17'],
	"OrderDate" TEXT -- example: ['5/31/18', '6/1/18'],
	"ShipDate" TEXT -- example: ['6/14/18', '6/22/18'],
	"DeliveryDate" TEXT -- example: ['6/19/18', '7/2/18'],
	"CurrencyCode" TEXT -- example: ['USD'],
	"_SalesTeamID" INTEGER -- example: ['14', '6'],
	"_CustomerID" INTEGER -- example: ['15', '20'],
	"_StoreID" INTEGER -- example: ['196', '259'],
	"_ProductID" INTEGER -- example: ['27', '12'],
	"Order Quantity" INTEGER -- example: ['5', '3'],
	"Discount Applied" REAL -- example: ['0.05', '0.075'],
	"Unit Price" TEXT -- example: ['3,939.60', '1,963.10'],
	"Unit Cost" TEXT -- example: ['3,348.66', '1,001.18'],
	PRIMARY KEY ("OrderNumber"), 
	CONSTRAINT fk_sales_orders_products FOREIGN KEY("_ProductID") REFERENCES "Products" ("ProductID"),
	FOREIGN KEY("_StoreID") REFERENCES "Store Locations" ("StoreID"), 
	CONSTRAINT fk_sales_orders_customers FOREIGN KEY("_CustomerID") REFERENCES "Customers" ("CustomerID"),
	FOREIGN KEY("_SalesTeamID") REFERENCES "Sales Team" ("SalesTeamID")
)


CREATE TABLE "Sales Team" (
	"SalesTeamID" INTEGER -- example: ['2', '1'],
	"Sales Team" TEXT -- example: ['Keith Griffin', 'Adam Hernandez'],
	"Region" TEXT -- example: ['West', 'Northeast'],
	PRIMARY KEY ("SalesTeamID")
)


CREATE TABLE "Store Locations" (
	"StoreID" INTEGER -- example: ['2', '1'],
	"City Name" TEXT -- example: ['Birmingham', 'Huntsville'],
	"County" TEXT -- example: ['Shelby County/Jefferson County', 'Limestone County/Madison County'],
	"StateCode" TEXT -- example: ['AL', 'AR'],
	"State" TEXT -- example: ['Arkansas', 'Alabama'],
	"Type" TEXT -- example: ['City', 'Town'],
	"Latitude" REAL -- example: ['34.69901', '33.52744'],
	"Longitude" REAL -- example: ['-86.67298', '-86.79905'],
	"AreaCode" INTEGER -- example: ['205', '256'],
	"Population" INTEGER -- example: ['212461', '190582'],
	"Household Income" INTEGER -- example: ['89972', '78554'],
	"Median Income" INTEGER -- example: ['31061', '48775'],
	"Land Area" INTEGER -- example: ['378353942', '552604579'],
	"Water Area" INTEGER -- example: ['6591013', '3452021'],
	"Time Zone" TEXT -- example: ['America/Chicago', 'America/Phoenix'],
	PRIMARY KEY ("StoreID"), 
	CONSTRAINT fk_store_locations_regions FOREIGN KEY("StateCode") REFERENCES "Regions" ("StateCode")
)

Question: How many states located in the Midwest region?

SQL:
SELECT COUNT(DISTINCT T) FROM ( SELECT CASE  WHEN Region = 'Midwest' THEN StateCode ELSE NULL END AS T FROM Regions ) WHERE T IS NOT NULL