Database schema:

CREATE TABLE app_all (
	app_id INTEGER NOT NULL -- example: ['-9223281467940916832', '-9222877069545393219'],
	PRIMARY KEY (app_id)
)


CREATE TABLE app_events (
	event_id INTEGER NOT NULL -- example: ['2', '6'],
	app_id INTEGER NOT NULL -- example: ['-8942695423876075857', '-8022267440849930066'],
	is_installed INTEGER NOT NULL -- example: ['1'],
	is_active INTEGER NOT NULL -- example: ['0', '1'],
	PRIMARY KEY (event_id, app_id), 
	CONSTRAINT fk_app_events_events FOREIGN KEY(event_id) REFERENCES events (event_id)
)


CREATE TABLE app_events_relevant (
	event_id INTEGER NOT NULL -- example: ['2', '6'],
	app_id INTEGER NOT NULL -- example: ['-8942695423876075857', '-8022267440849930066'],
	is_installed INTEGER DEFAULT NULL -- example: ['1'],
	is_active INTEGER DEFAULT NULL -- example: ['0', '1'],
	PRIMARY KEY (event_id, app_id), 
	CONSTRAINT fk_app_events_relevant_app_all FOREIGN KEY(app_id) REFERENCES app_all (app_id),
	CONSTRAINT fk_app_events_relevant_events_relevant FOREIGN KEY(event_id) REFERENCES events_relevant (event_id)
)


CREATE TABLE app_labels (
	app_id INTEGER NOT NULL -- example: ['7324884708820027918', '-4494216993218550286'],
	label_id INTEGER NOT NULL -- example: ['406', '251'],
	CONSTRAINT fk_app_labels_app_all FOREIGN KEY(app_id) REFERENCES app_all (app_id),
	CONSTRAINT fk_app_labels_label_categories FOREIGN KEY(label_id) REFERENCES label_categories (label_id)
)


CREATE TABLE events (
	event_id INTEGER NOT NULL -- example: ['2', '1'],
	device_id INTEGER DEFAULT NULL -- example: ['29182687948017175', '-6401643145415154744'],
	timestamp DATETIME DEFAULT NULL -- example: ['2016-05-01 00:55:25', '2016-05-01 00:54:12'],
	longitude REAL DEFAULT NULL -- example: ['121.0', '104.0'],
	latitude REAL DEFAULT NULL -- example: ['30.0', '31.0'],
	PRIMARY KEY (event_id)
)


CREATE TABLE events_relevant (
	event_id INTEGER NOT NULL, 
	device_id INTEGER DEFAULT NULL, 
	timestamp DATETIME NOT NULL, 
	longitude REAL NOT NULL, 
	latitude REAL NOT NULL, 
	PRIMARY KEY (event_id), 
	CONSTRAINT fk_events_relevant_gender_age FOREIGN KEY(device_id) REFERENCES gender_age (device_id)
)


CREATE TABLE gender_age (
	device_id INTEGER NOT NULL -- example: ['-9221079146476055829', '-9221086586254644858'],
	gender TEXT DEFAULT NULL -- example: ['M', 'F'],
	age INTEGER DEFAULT NULL -- example: ['31', '29'],
	"group" TEXT DEFAULT NULL -- example: ['M32-38', 'M29-31'],
	PRIMARY KEY (device_id), 
	CONSTRAINT fk_gender_age_phone_brand_device_model2 FOREIGN KEY(device_id) REFERENCES phone_brand_device_model2 (device_id)
)


CREATE TABLE gender_age_test (
	device_id INTEGER NOT NULL -- example: ['-9223321966609553846', '-9223042152723782980'],
	PRIMARY KEY (device_id)
)


CREATE TABLE gender_age_train (
	device_id INTEGER NOT NULL -- example: ['-9223067244542181226', '-9222956879900151005'],
	gender TEXT DEFAULT NULL -- example: ['M', 'F'],
	age INTEGER DEFAULT NULL -- example: ['24', '36'],
	"group" TEXT DEFAULT NULL -- example: ['M32-38', 'M23-26'],
	PRIMARY KEY (device_id)
)


CREATE TABLE label_categories (
	label_id INTEGER NOT NULL -- example: ['2', '1'],
	category TEXT DEFAULT NULL -- example: ['game-Game themes', 'game-game type'],
	PRIMARY KEY (label_id)
)


CREATE TABLE phone_brand_device_model2 (
	device_id INTEGER NOT NULL -- example: ['-9223321966609553846', '-9223067244542181226'],
	phone_brand TEXT NOT NULL -- example: ['小米', 'vivo'],
	device_model TEXT NOT NULL -- example: ['Y19T', '红米note'],
	PRIMARY KEY (device_id, phone_brand, device_model)
)


CREATE TABLE sample_submission (
	device_id INTEGER NOT NULL -- example: ['-9223321966609553846', '-9223042152723782980'],
	"F23-" REAL DEFAULT NULL -- example: ['0.0833'],
	"F24-26" REAL DEFAULT NULL -- example: ['0.0833'],
	"F27-28" REAL DEFAULT NULL -- example: ['0.0833'],
	"F29-32" REAL DEFAULT NULL -- example: ['0.0833'],
	"F33-42" REAL DEFAULT NULL -- example: ['0.0833'],
	"F43+" REAL DEFAULT NULL -- example: ['0.0833'],
	"M22-" REAL DEFAULT NULL -- example: ['0.0833'],
	"M23-26" REAL DEFAULT NULL -- example: ['0.0833'],
	"M27-28" REAL DEFAULT NULL -- example: ['0.0833'],
	"M29-31" REAL DEFAULT NULL -- example: ['0.0833'],
	"M32-38" REAL DEFAULT NULL -- example: ['0.0833'],
	"M39+" REAL DEFAULT NULL -- example: ['0.0833'],
	PRIMARY KEY (device_id)
)

Question: How many users of the app were not active when event no.2 happened?
Evidence: not active refers to is_active = 0; event no. refers to event_id; event_id = 2;

SQL:
SELECT COUNT(event_id) FROM app_events WHERE event_id = 2 AND is_active = 0