编写一存储过程,查询指定客户在指定时间段内购买指定产品的数量,存储过程中使用了输入和输出参数。并调用该存储过程查询名称为“家电市场”的客户在2004年购买“洗衣机”的数量。
- SQL code
create function getStock2(@customerName char(30),@time datetime,@productName char(30)) returns intasbegin declare @Stock int; select @Stock=cpxsb.数量 from cp,cpxsb,xss where cp.产品编号=cpxsb.产品编号 and cpxsb.客户编号=xss.客户编号 and [email protected] and [email protected] and [email protected] return @Stockend
然后测试的时候,@time参数那边就会有问题:要具体到月日,而不能做到题目要求的那样在2004年购买的
望哪位可以帮我这新手解答或提示,在此谢过。
------解决方案--------------------
- SQL code
create function getStock2(@customerName char(30),@time datetime,@productName char(30)) returns intasbegin declare @Stock int; select @Stock=cpxsb.数量 from cp,cpxsb,xss where cp.产品编号=cpxsb.产品编号 and cpxsb.客户编号=xss.客户编号 and [email protected] and [email protected] and 销售日期=year(@time) return @Stockend
------解决方案--------------------