呵呵,我所写的最长的SQL语句,作用:产品库存=初期创库+进货+退货-出货

lonaerd 2003-12-12 02:30:50
select ttti.id,ttti.productid,ttti.type,ttti.cirle,ttti.batno,ttti.fasion,ttti.netp,
ttti.editdate,ttti.userid,ttti.moneykind,(ttti.all2+isnull(kickback.amount,0)) as all3 from
(select tti.id,tti.productid,tti.type,tti.cirle,tti.batno,tti.fasion,tti.netp,
tti.editdate,tti.userid,tti.moneykind,(tti.all1-isnull(sale.amount,0)) as all2 from
(select ti.id,ti.productid,ti.type,ti.cirle,ti.batno,ti.fasion, ti.netp,ti.editdate,ti.userid,
ti.moneykind,(isum+isnull(orlignstore.amount,0)) as all1 from (select product.id ,product.productid,
product.type,product.cirle,product.batno,product.fasion, product.netp,product.editdate,
product.userid,sum(isnull(import.amount,0)) as isum,product.moneykind
from product left join import on product.type=import.type
group by product.id,product.productid,product.type,product.cirle,product.batno,
product.fasion, product.netp,product.editdate,product.userid,product.moneykind)
ti left join orlignstore on ti.type=orlignstore.type group by ti.id,ti.productid,
ti.type,ti.cirle,ti.batno,ti.fasion, ti.netp,ti.editdate,ti.userid,ti.isum,orlignstore.amount,
ti.moneykind) tti left join sale on tti.type=sale.type group by tti.id,tti.productid,tti.type,tti.cirle,tti.batno,tti.fasion,tti.netp,
tti.editdate,tti.userid,tti.moneykind,tti.all1,sale.amount) ttti left join kickback on ttti.type=kickback.type group by
ttti.id,ttti.productid,ttti.type,ttti.cirle,ttti.batno,ttti.fasion,ttti.netp,
ttti.editdate,ttti.userid,ttti.moneykind,ttti.all2,kickback.amount'
...全文
6 回复 打赏 收藏 举报
写回复
回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
相关推荐
发帖
ASP
加入

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
申请成为版主
帖子事件
创建了帖子
2003-12-12 02:30
社区公告
暂无公告