子查询返回的值多于一个。 当子查询跟随在 =、!=、<、<=、>、>=之后,或子查询用作表达式时,这种情况是
原文如下,请问如何修改:CREATEview生产通知单asSELECTto_produce.pnumas生产单号,to_produce.datesas生产日期,(sele...
原文如下,请问如何修改:
CREATE view 生产通知单
as
SELECT
to_produce.pnum as 生产单号,
to_produce.dates as 生产日期,
(select top 1 usernamec from ts_user where usercode = to_produce.usercode) as 制单员,
to_produce.inputdate as 制单日期,
(select top 1 deptnamec from ts_dept where deptcode = to_produce.deptcode) as 制单部门,
(select top 1 usernamec from ts_user where usercode = to_produce.salesman) as 业务员,
(select top 1 deptnamec from ts_dept where deptcode = to_produce.salesdept) as 业务部门,
(select top 1 custname from to_contract where connum = to_producegoods.connum) as 客户名称,
(select top 1 address from tb_cust where custcode = (select top 1 custcode from to_contract where connum = to_producegoods.connum)) as 客户地址,
to_produce.scyq as 生产要求,
to_produce.bzyq as 包装要求,
to_produce.remark as 备注,
to_producegoods.inputno as 序号,
to_producegoods.gcode as 商品代码,
to_producegoods.gnamec as 商品名称,
to_producegoods.gsizec as 商品规格,
to_producegoods.quty as 数量,
(select sum(quty) from to_producegoods where pnum = to_produce.pnum) as 数量合计,
to_producegoods.remark as 明细备注,
to_producegoods.connum as 出口合同号,
to_producegoods.shipdate as 出运日期,
to_producegoods.unit as 计量单位,
to_producegoods.scyq as 明细生产要求,
to_producegoods.bzyq as 明细包装要求,
(select price2 from to_contractgoods where gcode = to_producegoods.gcode and connum = to_producegoods.connum) as 原币单价,
(select fmone from to_contractgoods where gcode = to_producegoods.gcode and connum = to_producegoods.connum) as 原币金额,
(select sum(to_contractgoods.fmone) from to_contractgoods where connum = to_producegoods.connum) as 原币金额合计,
(select sum(to_contractgoods.fmone) from to_contractgoods where connum = to_producegoods.connum) as 合同总金额
FROM to_produce left outer join to_producegoods on to_produce.pnum = to_producegoods.pnum 展开
CREATE view 生产通知单
as
SELECT
to_produce.pnum as 生产单号,
to_produce.dates as 生产日期,
(select top 1 usernamec from ts_user where usercode = to_produce.usercode) as 制单员,
to_produce.inputdate as 制单日期,
(select top 1 deptnamec from ts_dept where deptcode = to_produce.deptcode) as 制单部门,
(select top 1 usernamec from ts_user where usercode = to_produce.salesman) as 业务员,
(select top 1 deptnamec from ts_dept where deptcode = to_produce.salesdept) as 业务部门,
(select top 1 custname from to_contract where connum = to_producegoods.connum) as 客户名称,
(select top 1 address from tb_cust where custcode = (select top 1 custcode from to_contract where connum = to_producegoods.connum)) as 客户地址,
to_produce.scyq as 生产要求,
to_produce.bzyq as 包装要求,
to_produce.remark as 备注,
to_producegoods.inputno as 序号,
to_producegoods.gcode as 商品代码,
to_producegoods.gnamec as 商品名称,
to_producegoods.gsizec as 商品规格,
to_producegoods.quty as 数量,
(select sum(quty) from to_producegoods where pnum = to_produce.pnum) as 数量合计,
to_producegoods.remark as 明细备注,
to_producegoods.connum as 出口合同号,
to_producegoods.shipdate as 出运日期,
to_producegoods.unit as 计量单位,
to_producegoods.scyq as 明细生产要求,
to_producegoods.bzyq as 明细包装要求,
(select price2 from to_contractgoods where gcode = to_producegoods.gcode and connum = to_producegoods.connum) as 原币单价,
(select fmone from to_contractgoods where gcode = to_producegoods.gcode and connum = to_producegoods.connum) as 原币金额,
(select sum(to_contractgoods.fmone) from to_contractgoods where connum = to_producegoods.connum) as 原币金额合计,
(select sum(to_contractgoods.fmone) from to_contractgoods where connum = to_producegoods.connum) as 合同总金额
FROM to_produce left outer join to_producegoods on to_produce.pnum = to_producegoods.pnum 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询