子查询返回超过1个值的错误

子查询返回超过1个值的错误

本文介绍了子查询返回超过1个值的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

select m.wagerefcode v,empname e,recorddate d,sum(finalamount) a,
(select isnull(vch_no,'') from ERP1314..SH_VCH_M_EXP where PN_VOUCHER = M.WageRefCode) as BMCM,
(select Convert(varchar,vch_Date,106) from ERP1314..SH_VCH_M_EXP where PN_VOUCHER = M.WageRefCode) as BMCMDate,
(select isnull(vch_no,'') from ERP1314..SH_VCH_M where PN_VOUCHER = M.WageRefCode) as BPCP,
(select Convert(varchar,vch_Date,106) from ERP1314..SH_VCH_M where PN_VOUCHER = M.WageRefCode) as BPCPDate
 from pr_dailywages_m m,pr_dailywages_d d,employee_m emp where emp.empid=m.empid and d.wagerefcode=m.wagerefcode and m.mainlocid in (2,11)
 and recorddate between '1/Sep/201' and '03/Oct/2013'  and m.cmp_id = 'SZS' Group by EmpName, m.WageRefCode,recorddate order by recorddate

推荐答案

(select isnull(vch_no,'') from ERP1314..SH_VCH_M_EXP where PN_VOUCHER = M.WageRefCode) as BMCM,
(select Convert(varchar,vch_Date,106) from ERP1314..SH_VCH_M_EXP where PN_VOUCHER = M.WageRefCode) as BMCMDate,




(select isnull(vch_no,'') from ERP1314..SH_VCH_M where PN_VOUCHER = M.WageRefCode) as BPCP,
(select Convert(varchar,vch_Date,106) from ERP1314..SH_VCH_M where PN_VOUCHER = M.WageRefCode) as BPCPDate





d是这样的事情





it should be something like this

(select TOP(1)isnull(vch_no,'') from ERP1314..SH_VCH_M_EXP where PN_VOUCHER = M.WageRefCode) as BMCM,




(select TOP(1)Convert(varchar,vch_Date,106) from ERP1314..SH_VCH_M_EXP where PN_VOUCHER = M.WageRefCode) as BMCMDate,




(select TOP(1)isnull(vch_no,'') from ERP1314..SH_VCH_M where PN_VOUCHER = M.WageRefCode) as BPCP,




(select TOP(1)Convert(varchar,vch_Date,106) from ERP1314..SH_VCH_M where PN_VOUCHER = M.WageRefCode) as BPCPDate


这篇关于子查询返回超过1个值的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-14 01:48