Aggregation with grouping
Scripts: See group.sql.
Schema
create table customer(
customer_id int not null primary key,
name varchar not null,
address varchar not null
);
create table purchase(
purchase_id int not null primary key,
customer_id int not null references customer,
purchase_date date not null,
product_id int not null references product,
quantity int not null,
total_due numeric(10,2) not null,
unpaid numeric(10, 2) not null
);
|