那个记录包装变更记录的表结构可以做成这样的table2: changeID pID old包装1 new包装1 ....设记录总价格变更的Table名称为table1,记录包装变更的Table为table2,先根据新和旧总价格在table1中找到changeID和pID,然后再根据changeID和pID去table2中找到当时各个包装的价格select old包装1,old... from table2 where changeID in (select changeID from table1 where oldprice='参数' and newprice='参数') and pID in (select changeID from table1 where oldprice='参数' and newprice='参数')或者干脆两个表做连接查找:select old包装1,old.... from table1 left join table2 on table1.changeID=table2.changeId and table1.pID=table2.pID where oldprice='参数' and newprice='参数'思路应该就是这样的。
统计SQL来处理。 设计两个表一个表为产品表 产品表 产品ID 产品价格 包装表 包装ID 产品ID 包装价格 select * from 产品表 right join 包装表 on 产品表.产品ID=包装表.产品ID
这是变更记录表
假如 PID 123 和 124 在某一个产品下, 现在这个产品的 价格是 7+4=1
我要找 原来产品单价是 6+4=10 的那个时候的 这两个包装的价格 只知道产品的价格
,和当前包装价格 123 = 7 ,124=4changeID pID odlPrice newPrice
-------------------------------------------------------
1 123 5 6
2 124 2 3
3 124 3 4
4 123 6 4
5 123 4 7
changeID pID old包装1 new包装1 ....设记录总价格变更的Table名称为table1,记录包装变更的Table为table2,先根据新和旧总价格在table1中找到changeID和pID,然后再根据changeID和pID去table2中找到当时各个包装的价格select old包装1,old... from table2
where changeID in (select changeID from table1 where oldprice='参数' and newprice='参数') and pID in (select changeID from table1 where oldprice='参数' and newprice='参数')或者干脆两个表做连接查找:select old包装1,old....
from table1 left join table2 on table1.changeID=table2.changeId and table1.pID=table2.pID
where oldprice='参数' and newprice='参数'思路应该就是这样的。
设计两个表一个表为产品表
产品表 产品ID 产品价格
包装表 包装ID 产品ID 包装价格 select * from 产品表 right join 包装表 on 产品表.产品ID=包装表.产品ID
每改变一次产品价格,就填写到产品表中,每改变一次包装价格也添加记录到包装表中
已知SUM(P1,P2,P3.....Pm) = M;
P1属于集合(P11...P1n);
P2属于集合(P21...P2n);
.
.
.
Pm属于集合(Pm1...Pmn);
n为P变更次数;
求(P1,P2,P3...Pm)解的集合
....................................
算法怎么写最滥就迭代吧
已知SUM(P1,P2,P3.....Pm) = M;
P1属于集合(P11...P1n);
P2属于集合(P21...P2n);
.
.
.
Pm属于集合(Pm1...Pmn);
n为P变更次数;
求(P1,P2,P3...Pm)解的集合
....................................
算法怎么写最滥就迭代吧