以赛代练,诚怔面试题

铁歌 2005-08-22 04:04:32
以赛代练,诚怔面试题
...全文
173 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
ymfhcn 2006-03-13
  • 打赏
  • 举报
回复
表结构如下:
item(itemno(varchar(20)),in_price(float),out_price(float))----itemno:产品编号,in_price:采购价,out_price:销售价.
INOut_list(itemno (varchar(20)),flag(char(1),qty(int))---itemno:产品编号,flag:标志,其中flag=1表示入仓,flag=2表示出仓.qty:入仓或出仓数量.

1.用一条SQL列出 仓存;
2.用一条SQL列出 每个产品的库存金额;
3.用一条SQL列出 所有产品的库存金额.




1.用一条SQL列出 仓存;
select itemno,sum(qty)-(select sum(qty) from inout_list a where a.itemno=b.itemno and flag=0 group by itemno)
from inout_list b where flag=1 group by itemno

2.用一条SQL列出 每个产品的库存金额;
select itemno,sum(qty)*(select in_price from item where itemno=b.itemno)
-(select sum(qty) from inout_list a where a.itemno=b.itemno and flag=0 group by itemno)*
(select out_price from item where itemno=b.itemno) )
from inout_list b where flag=1 group by itemno

3.用一条SQL列出 所有产品的库存金额.
select itemno,sum(库存) as 总库存 from
(
select itemno,库存=sum(qty)*(select in_price from item where itemno=b.itemno)
-(select sum(qty) from inout_list a where a.itemno=b.itemno and flag=0 group by itemno)*
(select out_price from item where itemno=b.itemno) )
from inout_list b where flag=1 group by itemno
) a
group by itemno
ccghghgj 2005-08-22
  • 打赏
  • 举报
回复
顶一个。

===============================
CSDN小助手 是一款脱离浏览器也可以使用csdn论坛的
软件!
界面: http://qqwwee.com/
下载: http://qqwwee.com/csdn.rar 包含源代码

34,575

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧