Database schema:

CREATE TABLE employee (
	employee_id INTEGER -- example: ['103705', '104633'],
	first_name TEXT -- example: ['Anastasia', 'Joshua'],
	last_name TEXT -- example: ['Rosa', 'Hansen'],
	address TEXT -- example: ['6023 S Elizabeth St', '5000 N Wolcott Ave'],
	city TEXT -- example: ['Park Forest', 'Chicago'],
	state TEXT -- example: ['IL'],
	zip INTEGER -- example: ['60640', '60636'],
	phone TEXT -- example: ['(773) 424-8729', '(773) 293-6409'],
	title TEXT -- example: ['Sanitarian', 'Supervisor'],
	salary INTEGER -- example: ['79300', '82000'],
	supervisor INTEGER -- example: ['186742', '177316'],
	PRIMARY KEY (employee_id), 
	CONSTRAINT fk_employee_employee FOREIGN KEY(supervisor) REFERENCES employee (employee_id)
)


CREATE TABLE establishment (
	license_no INTEGER -- example: ['2', '1'],
	dba_name TEXT -- example: ['COSI', 'HARVEST CRUSADES MINISTRIES'],
	aka_name TEXT -- example: ["KING'S CHINESE/PARK MANOR LOUNGE", 'COSI'],
	facility_type TEXT -- example: ['Restaurant', 'Special Event'],
	risk_level INTEGER -- example: ['2', '1'],
	address TEXT -- example: ['118 N CENTRAL AVE ', '230 W MONROE ST '],
	city TEXT -- example: ['Chicago', 'CHICAGO'],
	state TEXT -- example: ['IL'],
	zip INTEGER -- example: ['60606', '60644'],
	latitude REAL -- example: ['41.8828450747188', '41.8807571586472'],
	longitude REAL -- example: ['-87.7650954520439', '-87.6347092983425'],
	ward INTEGER -- example: ['42', '29'],
	PRIMARY KEY (license_no)
)


CREATE TABLE inspection (
	inspection_id INTEGER -- example: ['44248', '44247'],
	inspection_date DATE -- example: ['2010-01-05', '2010-01-21'],
	inspection_type TEXT -- example: ['Complaint', 'Canvass'],
	results TEXT -- example: ['Pass w/ Conditions', 'Pass'],
	employee_id INTEGER -- example: ['141319', '143902'],
	license_no INTEGER -- example: ['1336561', '1222441'],
	followup_to INTEGER -- example: ['67871', '248210'],
	PRIMARY KEY (inspection_id), 
	CONSTRAINT fk_inspection_employee FOREIGN KEY(employee_id) REFERENCES employee (employee_id),
	CONSTRAINT fk_inspection_establishment FOREIGN KEY(license_no) REFERENCES establishment (license_no),
	CONSTRAINT fk_inspection_inspection FOREIGN KEY(followup_to) REFERENCES inspection (inspection_id)
)


CREATE TABLE inspection_point (
	point_id INTEGER -- example: ['2', '1'],
	"Description" TEXT -- example: ['Facilities to maintain proper temperature', 'Source sound condition, no spoilage, foods properl'],
	category TEXT -- example: ['Food Equipment and Utensil Sanitation', 'Food Protection'],
	code TEXT -- example: ['7-38-005 (A)', '7-38-005 (B) (B-2)'],
	fine INTEGER -- example: ['250', '500'],
	point_level TEXT -- example: ['Critical', 'Serious '],
	PRIMARY KEY (point_id)
)


CREATE TABLE violation (
	inspection_id INTEGER -- example: ['44248', '44247'],
	point_id INTEGER -- example: ['30', '32'],
	fine INTEGER -- example: ['0', '100'],
	inspector_comment TEXT -- example: ["OBSERVED TORN DOOR GASKET ON DOOR OF 'CHILL ISLE' ", 'All food not stored in the original container shal'],
	PRIMARY KEY (inspection_id, point_id), 
	CONSTRAINT fk_violation_inspection FOREIGN KEY(inspection_id) REFERENCES inspection (inspection_id),
	CONSTRAINT fk_violation_inspection_point FOREIGN KEY(point_id) REFERENCES inspection_point (point_id)
)

Question: How many taverns failed in July 2010?
Evidence: tavern refers to facility_type = 'Tavern'; failed refers to results = 'Fail'; in July 2010 refers to inspection_date like '2010-07%'

SQL:
SELECT COUNT(DISTINCT T1.license_no) FROM establishment AS T1 INNER JOIN inspection AS T2 ON T1.license_no = T2.license_no WHERE strftime('%Y-%m', T2.inspection_date) = '2010-07' AND T2.results = 'Fail' AND T1.facility_type = 'Restaurant'