//物流系统。
//仓库:仓库号,仓库名,地点
//货物:货物号,货物名称,单价。
//物流表:仓库号,货物号,出入库数量,时间。
//需求:
// 1,用sql建立三个表。主,外键。
// 2,使用sql语句查询,单价高于100元的货物名,出入库总次数,总数量。
creat table cangku
(
canno smallint primary key,
canname varchar(20) not null,
place varchar(20) not null
);
creat table goods
(
goodsno smallint primary key,
goodsname varchar(20) not null,
goodsval smallint not null
);
creat table gft
(
canno smallint,
goodsno smallint,
lots int,
lottime datatime,
primary key(canno,goodsno),
foreign key(goodsno) reference goods(goosno),
foreign key(canno) reference cangku(canno)
);
单价高于100的货物名:
select goodsname
from goods
where goodsval>100;
出入库总次数
select count(datatime)
from gft
group by datatime;
总数量
seletct sum(lots)
from gft;