
CREATE TABLE "ACCOUNTS" (
	custid BIGINT NOT NULL, 
	name VARCHAR(64) NOT NULL, 
	PRIMARY KEY (custid)
)


CREATE TABLE "CHECKING" (
	custid BIGINT NOT NULL, 
	balance FLOAT NOT NULL, 
	PRIMARY KEY (custid), 
	FOREIGN KEY(custid) REFERENCES "ACCOUNTS" (custid)
)


CREATE TABLE "SAVINGS" (
	custid BIGINT NOT NULL, 
	balance FLOAT NOT NULL, 
	PRIMARY KEY (custid), 
	FOREIGN KEY(custid) REFERENCES "ACCOUNTS" (custid)
)

CREATE TABLE "ACCOUNTS" (
	custid BIGINT NOT NULL, 
	name VARCHAR(64) NOT NULL, 
	PRIMARY KEY (custid)
)

/*
2 rows from ACCOUNTS table:
custid	name
1	Brown
2	Wang
*/


CREATE TABLE "CHECKING" (
	custid BIGINT NOT NULL, 
	balance FLOAT NOT NULL, 
	PRIMARY KEY (custid), 
	FOREIGN KEY(custid) REFERENCES "ACCOUNTS" (custid)
)

/*
2 rows from CHECKING table:
custid	balance
1	10000.0
2	2000.0
*/


CREATE TABLE "SAVINGS" (
	custid BIGINT NOT NULL, 
	balance FLOAT NOT NULL, 
	PRIMARY KEY (custid), 
	FOREIGN KEY(custid) REFERENCES "ACCOUNTS" (custid)
)

/*
2 rows from SAVINGS table:
custid	balance
1	200000.0
2	999999999.0
*/
What are the names of customers with a higher checking balance than savings balance?
SELECT T1.name FROM accounts AS T1 JOIN checking AS T2 ON T1.custid  =  T2.custid JOIN savings AS T3 ON T1.custid  =  T3.custid WHERE T2.balance  >  T3.balance
[{'name': 'Weeks'}]