### Database Schema:
CREATE TABLE jobs (
	job_id	INTEGER	NULL	PRIMARY KEY,
	job_desc	TEXT	NOT NULL,
	min_lvl	INTEGER	NOT NULL,
	max_lvl	INTEGER	NOT NULL
);

CREATE TABLE stores (
	stor_id	TEXT	NULL	PRIMARY KEY,
	stor_name	TEXT	NULL,
	stor_address	TEXT	NULL,
	city	TEXT	NULL,
	state	TEXT	NULL,
	zip	TEXT	NULL
);

CREATE TABLE publishers (
	pub_id	TEXT	NULL	PRIMARY KEY,
	pub_name	TEXT	NULL,
	city	TEXT	NULL,
	state	TEXT	NULL,
	country	TEXT	NULL
);

CREATE TABLE employee (
	emp_id	TEXT	NULL	PRIMARY KEY,
	fname	TEXT	NOT NULL,
	minit	TEXT	NULL,
	lname	TEXT	NOT NULL,
	job_id	INTEGER	NOT NULL,
	job_lvl	INTEGER	NULL,
	pub_id	TEXT	NOT NULL,
	hire_date	DATETIME	NOT NULL,
	foreign key (job_id) references jobs (job_id),
	foreign key (pub_id) references publishers (pub_id)
);

CREATE TABLE authors (
	au_id	TEXT	NULL	PRIMARY KEY,
	au_lname	TEXT	NOT NULL,
	au_fname	TEXT	NOT NULL,
	phone	TEXT	NOT NULL,
	address	TEXT	NULL,
	city	TEXT	NULL,
	state	TEXT	NULL,
	zip	TEXT	NULL,
	contract	TEXT	NOT NULL
);

CREATE TABLE roysched (
	title_id	TEXT	NOT NULL,
	lorange	INTEGER	NULL,
	hirange	INTEGER	NULL,
	royalty	INTEGER	NULL,
	foreign key (title_id) references titles (title_id)
);

CREATE TABLE pub_info (
	pub_id	TEXT	NULL	PRIMARY KEY,
	logo	BLOB	NULL,
	pr_info	TEXT	NULL,
	foreign key (pub_id) references publishers (pub_id)
);

CREATE TABLE titles (
	title_id	TEXT	NULL	PRIMARY KEY,
	title	TEXT	NOT NULL,
	type	TEXT	NOT NULL,
	pub_id	TEXT	NULL,
	price	REAL	NULL,
	advance	REAL	NULL,
	royalty	INTEGER	NULL,
	ytd_sales	INTEGER	NULL,
	notes	TEXT	NULL,
	pubdate	DATETIME	NOT NULL,
	foreign key (pub_id) references publishers (pub_id)
);

CREATE TABLE sales (
	stor_id	TEXT	NOT NULL	PRIMARY KEY,
	ord_num	TEXT	NOT NULL	PRIMARY KEY,
	ord_date	DATETIME	NOT NULL,
	qty	INTEGER	NOT NULL,
	payterms	TEXT	NOT NULL,
	title_id	TEXT	NOT NULL	PRIMARY KEY,
	foreign key (title_id) references titles (title_id),
	foreign key (stor_id) references stores (stor_id)
);

CREATE TABLE discounts (
	discounttype	TEXT	NOT NULL,
	stor_id	TEXT	NULL,
	lowqty	INTEGER	NULL,
	highqty	INTEGER	NULL,
	discount	REAL	NOT NULL,
	foreign key (stor_id) references stores (stor_id)
);

CREATE TABLE titleauthor (
	au_id	TEXT	NOT NULL	PRIMARY KEY,
	title_id	TEXT	NOT NULL	PRIMARY KEY,
	au_ord	INTEGER	NULL,
	royaltyper	INTEGER	NULL,
	foreign key (au_id) references authors (au_id),
	foreign key (title_id) references titles (title_id)
);

### User's Query:
How many books on business have the bookstores in Massachusetts ordered?

### Extra Knowledge:
Massachusetts is a state; business books refers to type = 'business'
SELECT SUM(T1.qty) FROM sales AS T1 INNER JOIN stores AS T2 ON T1.stor_id = T2.stor_id INNER JOIN titles AS T3 ON T1.title_id = T3.title_id WHERE T2.state = 'Massachusetts' AND T3.type = 'business'