子查询返回的值多于一个。 当子查询跟随在 =、!=、<、<=、>、>=之后,或子查询用作表达式时,这种情况是

原文如下,请问如何修改: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
展开
 我来答
太马小1D
2016-11-10 · TA获得超过349个赞
知道小有建树答主
回答量:397
采纳率:80%
帮助的人:66.2万
展开全部
这就说明了你想把查询出来的一个结果赋值给某个东西,但是呢你查询出来的结果呢不止一个,有多个,这时候sql语句就会报这个提示信息
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式