Database schema:

CREATE TABLE "order" (
	order_id INTEGER DEFAULT 0 NOT NULL -- example: ['29402', '29401'],
	account_id INTEGER NOT NULL -- example: ['2', '1'],
	bank_to TEXT NOT NULL -- bank of the recipient, example: ['YZ', 'ST'],
	account_to INTEGER NOT NULL -- account of the recipient, example: ['87144583', '89597016'],
	amount REAL NOT NULL -- debited amount, example: ['2452.0', '3372.7'],
	k_symbol TEXT NOT NULL -- characterization of the payment, example: ['SIPO', 'UVER'],
	PRIMARY KEY (order_id), 
	CONSTRAINT fk_order_account FOREIGN KEY(account_id) REFERENCES account (account_id)
)


CREATE TABLE account (
	account_id INTEGER DEFAULT 0 NOT NULL -- account id, example: ['2', '1'],
	district_id INTEGER DEFAULT 0 NOT NULL -- location of branch, example: ['1', '18'],
	frequency TEXT NOT NULL -- example: ['POPLATEK TYDNE', 'POPLATEK MESICNE'],
	date DATE NOT NULL -- example: ['1993-02-26', '1995-03-24'],
	PRIMARY KEY (account_id), 
	CONSTRAINT fk_account_district FOREIGN KEY(district_id) REFERENCES district (district_id)
)


CREATE TABLE card (
	card_id INTEGER DEFAULT 0 NOT NULL -- credit card id, example: ['2', '1'],
	disp_id INTEGER NOT NULL -- disposition id, example: ['9', '19'],
	type TEXT NOT NULL -- example: ['gold', 'classic'],
	issued DATE NOT NULL -- example: ['1998-03-13', '1998-10-16'],
	PRIMARY KEY (card_id), 
	CONSTRAINT fk_card_disp FOREIGN KEY(disp_id) REFERENCES disp (disp_id)
)


CREATE TABLE client (
	client_id INTEGER NOT NULL -- example: ['2', '1'],
	gender TEXT NOT NULL -- example: ['M', 'F'],
	birth_date DATE NOT NULL -- example: ['1970-12-13', '1945-02-04'],
	district_id INTEGER NOT NULL -- location of branch, example: ['1', '18'],
	PRIMARY KEY (client_id), 
	CONSTRAINT fk_client_district FOREIGN KEY(district_id) REFERENCES district (district_id)
)


CREATE TABLE disp (
	disp_id INTEGER NOT NULL -- disposition id, example: ['2', '1'],
	client_id INTEGER NOT NULL -- example: ['2', '1'],
	account_id INTEGER NOT NULL -- example: ['2', '1'],
	type TEXT NOT NULL -- example: ['OWNER', 'DISPONENT'],
	PRIMARY KEY (disp_id), 
	CONSTRAINT fk_disp_account FOREIGN KEY(account_id) REFERENCES account (account_id),
	CONSTRAINT fk_disp_client FOREIGN KEY(client_id) REFERENCES client (client_id)
)


CREATE TABLE district (
	district_id INTEGER DEFAULT 0 NOT NULL -- location of branch, example: ['2', '1'],
	"A2" TEXT NOT NULL -- district_name, example: ['Hl.m. Praha', 'Benesov'],
	"A3" TEXT NOT NULL -- region, example: ['central Bohemia', 'Prague'],
	"A4" TEXT NOT NULL -- number of inhabitants, example: ['88884', '1204953'],
	"A5" TEXT NOT NULL -- no. of municipalities with inhabitants < 499, example: ['0', '80'],
	"A6" TEXT NOT NULL -- no. of municipalities with inhabitants 500-1999, example: ['0', '26'],
	"A7" TEXT NOT NULL -- no. of municipalities with inhabitants 2000-9999, example: ['0', '6'],
	"A8" INTEGER NOT NULL -- no. of municipalities with inhabitants > 10000, example: ['2', '1'],
	"A9" INTEGER NOT NULL -- example: ['5', '1'],
	"A10" REAL NOT NULL -- ratio of urban inhabitants, example: ['46.7', '100.0'],
	"A11" INTEGER NOT NULL -- average salary, example: ['8507', '12541'],
	"A12" REAL -- unemployment rate 1995, example: ['0.2', '1.6'],
	"A13" REAL NOT NULL -- unemployment rate 1996, example: ['1.85', '0.43'],
	"A14" INTEGER NOT NULL -- no. of entrepreneurs per 1000 inhabitants, example: ['132', '167'],
	"A15" INTEGER -- no. of committed crimes 1995, example: ['85677', '2159'],
	"A16" INTEGER NOT NULL -- no. of committed crimes 1996, example: ['2674', '99107'],
	PRIMARY KEY (district_id)
)


CREATE TABLE loan (
	loan_id INTEGER DEFAULT 0 NOT NULL -- example: ['4961', '4959'],
	account_id INTEGER NOT NULL -- example: ['2', '19'],
	date DATE NOT NULL -- example: ['1996-04-29', '1994-01-05'],
	amount INTEGER NOT NULL -- example: ['80952', '30276'],
	duration INTEGER NOT NULL -- example: ['24', '12'],
	payments REAL NOT NULL -- monthly payments, example: ['2523.0', '3373.0'],
	status TEXT NOT NULL -- example: ['A', 'B'],
	PRIMARY KEY (loan_id), 
	CONSTRAINT fk_loan_account FOREIGN KEY(account_id) REFERENCES account (account_id)
)


CREATE TABLE trans (
	trans_id INTEGER DEFAULT 0 NOT NULL -- transaction id, example: ['5', '1'],
	account_id INTEGER DEFAULT 0 NOT NULL -- example: ['2', '1'],
	date DATE NOT NULL -- date of transaction, example: ['1995-04-13', '1995-03-24'],
	type TEXT NOT NULL -- +/- transaction, example: ['PRIJEM', 'VYDAJ'],
	operation TEXT -- mode of transaction, example: ['VKLAD', 'PREVOD Z UCTU'],
	amount INTEGER NOT NULL -- amount of money, example: ['3679', '1000'],
	balance INTEGER NOT NULL -- balance after transaction, example: ['1000', '4679'],
	k_symbol TEXT -- characterization of the transaction, example: ['SLUZBY', 'SIPO'],
	bank TEXT -- bank of the partner, example: ['AB', 'YZ'],
	account INTEGER -- account of the partner, example: ['87144583', '41403269'],
	PRIMARY KEY (trans_id), 
	CONSTRAINT fk_trans_account FOREIGN KEY(account_id) REFERENCES account (account_id)
)

Question: How many loan accounts are for pre-payment of duration of 24 months with weekly issuance of statement.
Evidence: Frequency = 'POPLATEK TYDNE' referes to weekly statement

SQL:
SELECT COUNT(T2.account_id) FROM account AS T1 INNER JOIN loan AS T2 ON T1.account_id = T2.account_id WHERE T2.duration = 24 AND T1.frequency = 'POPLATEK TYDNE'