|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册账号
×
数据库名: UFDATA_008_2019
C:\U8SOFT\Admin\SQLFILE11000\Main\Ufdata\Structure\DATA_PRV_FA_MIX_NL.sql
错误信息:
-2147217900
使用 UNION、INTERSECT 或 EXCEPT 运算符合并的所有查询必须在其目标列表中有相同数目的表达式。
执行如下语句时出错:
ALTER view [dbo].[fa_ZWVouchers_vw]
as
---卡片\资产减少(fa_cards)、变动单(fa_Vouchers)、折旧计提(fa_DeprVoucherMain)、评估资产(fa_V_EvaluateMain)
---加上code主要是对本币科目直接取本币币种,这样可以合并成功
select distinct
fa_ZwVouchers.i_id,coutaccset,ioutyear,coutsysname,coutsysver,doutbilldate,ioutperiod,coutsign,coutno_id,inid,doutdate,coutbillsign
,coutid,csign,idoc,cbill,ccashier,iflag,ctext1,ctext2,cdigest,fa_ZwVouchers.ccode,md,mc,md_f,mc_f,nfrat,nd_s,nc_s,csettle
,cn_id,dt_date,cdept_id,cperson_id,ccus_id,csup_id,citem_id,citem_class,cname,ccode_equal,bvouchedit,bvouchAddordele
,bvouchmoneyhold,bvalueedit,bcodeedit,ccodecontrol,bPCSedit,bDeptedit,bItemedit,bCusSupInput,cDefine1,cDefine2
,cDefine3,cDefine4,cDefine5,cDefine6,cDefine7,cDefine8,cDefine9,cDefine10,cDefine11,cDefine12,cDefine13,cDefine14
,cDefine15,cDefine16,cPzPropVal1,cPzPropVal2,cPzPropVal3,cPzPropVal4,fa_ZwVouchers.cexch_name as cexch_name_Orig,
case when code.cexch_name is null then ( select top 1 cexch_name from foreigncurrency where iotherused=-1)
else fa_cards.sCurrency end as cexch_name
from fa_ZwVouchers
inner join fa_cards on fa_ZwVouchers.coutno_id=fa_cards.sCardNum
left join code
on fa_ZWVouchers.ccode=code.ccode and code.iYear = dbo.Fa_GetLoginYear()
where coutsign='卡片'
union all
--资产减少
select distinct
fa_ZwVouchers.i_id,coutaccset,ioutyear,coutsysname,coutsysver,doutbilldate,ioutperiod,coutsign,coutno_id,inid,doutdate,coutbillsign
,coutid,csign,idoc,cbill,ccashier,iflag,ctext1,ctext2,cdigest,fa_ZwVouchers.ccode,md,mc,md_f,mc_f,nfrat,nd_s,nc_s,csettle
,cn_id,dt_date,cdept_id,cperson_id,ccus_id,csup_id,citem_id,citem_class,cname,ccode_equal,bvouchedit,bvouchAddordele
,bvouchmoneyhold,bvalueedit,bcodeedit,ccodecontrol,bPCSedit,bDeptedit,bItemedit,bCusSupInput,cDefine1,cDefine2
,cDefine3,cDefine4,cDefine5,cDefine6,cDefine7,cDefine8,cDefine9,cDefine10,cDefine11,cDefine12,cDefine13,cDefine14
,cDefine15,cDefine16,cPzPropVal1,cPzPropVal2,cPzPropVal3,cPzPropVal4,fa_ZwVouchers.cexch_name as cexch_name_Orig,
case when code.cexch_name is null then ( select top 1 cexch_name from foreigncurrency where iotherused=-1)
else fa_cards.sCurrency end as cexch_name
from fa_ZwVouchers
inner join fa_cards on fa_ZwVouchers.coutno_id=fa_cards.sCardNum
left join code
on fa_ZWVouchers.ccode=code.ccode and code.iYear = dbo.Fa_GetLoginYear()
where coutsign='资产减少'
union all
--变动单
select distinct
fa_ZwVouchers.i_id,coutaccset,ioutyear,coutsysname,coutsysver,doutbilldate,ioutperiod,coutsign,coutno_id,inid,doutdate,coutbillsign
,coutid,csign,idoc,cbill,ccashier,iflag,ctext1,ctext2,cdigest,fa_ZwVouchers.ccode,md,mc,md_f,mc_f,nfrat,nd_s,nc_s,csettle
,cn_id,dt_date,cdept_id,cperson_id,ccus_id,csup_id,citem_id,citem_class,cname,ccode_equal,bvouchedit,bvouchAddordele
,bvouchmoneyhold,bvalueedit,bcodeedit,ccodecontrol,bPCSedit,bDeptedit,bItemedit,bCusSupInput,cDefine1,cDefine2
,cDefine3,cDefine4,cDefine5,cDefine6,cDefine7,cDefine8,cDefine9,cDefine10,cDefine11,cDefine12,cDefine13,cDefine14
,cDefine15,cDefine16,cPzPropVal1,cPzPropVal2,cPzPropVal3,cPzPropVal4,fa_ZwVouchers.cexch_name as cexch_name_Orig,
case when code.cexch_name is null then ( select top 1 cexch_name from foreigncurrency where iotherused=-1)
else fa_cards.sCurrency end as cexch_name
from fa_ZwVouchers
inner join fa_Vouchers on fa_ZwVouchers.coutno_id=fa_Vouchers.sNum
left join fa_cards on fa_Vouchers.sCardNum=fa_cards.sCardNum
left join code
on fa_ZWVouchers.ccode=code.ccode and code.iYear = dbo.Fa_GetLoginYear()
where coutsign='变动单'
union all
--fa_V_DeprVoucherMain
--折旧计提 没有外币之说
select distinct
tmpZwVoucher.*,foreigcur.cexch_name
from
(
select fa_ZwVouchers.* from fa_ZwVouchers
inner join fa_V_DeprVoucherMain on fa_ZwVouchers.coutno_id=fa_V_DeprVoucherMain.sNum
where coutsign='折旧计提'
) as tmpZwVoucher
,
(
select cexch_code,cexch_name from foreigncurrency where iotherused=-1
) as foreigcur
union all
--评估资产
select distinct
fa_ZwVouchers.i_id,coutaccset,ioutyear,coutsysname,coutsysver,doutbilldate,ioutperiod,coutsign,coutno_id,inid,doutdate,coutbillsign
,coutid,csign,idoc,cbill,ccashier,iflag,ctext1,ctext2,cdigest,fa_ZwVouchers.ccode,md,mc,md_f,mc_f,nfrat,nd_s,nc_s,csettle
,cn_id,dt_date,cdept_id,cperson_id,ccus_id,csup_id,citem_id,citem_class,cname,ccode_equal,bvouchedit,bvouchAddordele
,bvouchmoneyhold,bvalueedit,bcodeedit,ccodecontrol,bPCSedit,bDeptedit,bItemedit,bCusSupInput,cDefine1,cDefine2
,cDefine3,cDefine4,cDefine5,cDefine6,cDefine7,cDefine8,cDefine9,cDefine10,cDefine11,cDefine12,cDefine13,cDefine14
,cDefine15,cDefine16,cPzPropVal1,cPzPropVal2,cPzPropVal3,cPzPropVal4,fa_ZwVouchers.cexch_name as cexch_name_Orig,
case when code.cexch_name is null then ( select top 1 cexch_name from foreigncurrency where iotherused=-1)
else fa_cards.sCurrency end as cexch_name
from fa_ZwVouchers
inner join fa_v_EvaluateVouchers on fa_ZwVouchers.coutno_id=fa_v_EvaluateVouchers.sNum
inner join fa_Cards on fa_v_EvaluateVouchers.sNum=fa_Cards.sEvaluateNum
and fa_v_EvaluateVouchers.sCardNum=fa_Cards.sCardNum
left join code
on fa_ZWVouchers.ccode=code.ccode and code.iYear = dbo.Fa_GetLoginYear()
where coutsign='评估资产'
|
|