关于数据库问题SQL问题

来源:百度知道 编辑:UC知道 时间:2024/07/02 06:18:43
用于生产计划的预算。
如客户给1个订单 有A产品10个 、B产品20个 两种产品。产品都分工序。我需要预算,所有的产品,按工序分,总时间为多少。例子:

(05 10 15 是工序代号,不用管, 0.1 0.2 0.3 指需加工的小时)
A产品 05 下料 0.1
10 数车 0.2
15 数铣 0.3
B产品 05 下料 0.2
10 数车 0.1
15 数铣 0.2
我需要做的是。把A B 产品这些工序存入数据库(最好是存入SQL2005)
然后。接到客户的订单。A 10个 B20个。
经过自动汇总后,
结果是
下料 0.1*10+0.2*20=5
数车 0.2*10+0.1*20=4
数铣 0.3*10+0.2*20=7

我只要按工序分 ,得出等号后面的数值。(因为电脑会自动汇总)
像这种数据库很简单。
问题是我不是计算机专业的,所以上来请教。
欢迎加QQ348863222 交流
客户提供的A B产品清单,一般是excel文件格式的。

--建A表,没插入数据
create table A_pro(
id char(4) not null primary key,
name_1 char(4),
needtime float)

--建B表
create table B_pro(
id char(4) not null primary key,
name_1 char(4),
needtime float)

--建汇总表
create table huizong(
id char(4) not null primary key,
name_1 char(4),
sumtime float)
--创建存储过程,用来计算
create proc jisuan2 @a int,@b int
as
insert into huizong(id,name_1)
select id,name_1 from A_pro
update huizong
set sumtime=0.1*@a+0.2*@b
where huizong.id=05
update huizong
set sumtime=0.2*@a+0.1*@b
where huizong.id=10
update huizong
set sumtime=0.3*@a+0.2*@b
where huizong.id=15
select * from huizong

--执行存储过程
exec jisuan2 '10','20'

请问你的产品时以什么计算 ??
天, 时或秒????