云顶集团用户登录「官方网站」

热门关键词: 云顶集团用户登录,云顶集团登录网站
来自 新闻动态 2020-01-05 19:21 的文章
当前位置: 云顶集团用户登录 > 新闻动态 > 正文

SQL server 和 Oracle 中列转行的小操作

Oracle:

SQL数据抽取,现身数据类型转变错误,求大神援救看一下。 1C
select a.patient_id+'_'+cast(a.item_no as varchar+'_'+cast(a.ledger_sn as varchar pk_pay,null pk_dcpv,null pvcode,'SDDYRMYY_G' code_group,'SDDYRMYY' code_org ,
cheque_type code_pay_mode,b.name name_pay_mode,a.charge amount,convert(varchar,a.dcount_date,120) date_pay, 'O' code_pvtype,
case when a.charge>=0 then 5 when a.charge<0 then 2 end dt_paytype,a.dcount_id code_psn_pay,psn.name name_psn_pay,mz_dept_no code_dept_pay
from mz_deposit_b a
left join zd_cheque_type b on a.cheque_type = b.code
left join a_employee_mi psn on psn.code = a.dcount_id
--WHERE a.dcount_date between ${BEGIN_DATE} and ${END_DATE}

create table zjhis.mz_zdxx_zl

where EXISTS
(
select patient_id,times
from uh_dc_pi_temp t
where t.patient_id=a.patient_id
)
union all
select a.patient_id+'_'+cast(a.item_no as varchar+'_'+cast(a.ledger_sn as varchar pk_pay,'O' code_pvtype,
a.patient_id+'_'+convert(varchar,times) pk_dcpv,a.patient_id+convert(varchar,times) pvcode,'SDDYRMYY_G' code_group,'SDDYRMYY' code_org ,
cheque_type code_pay_mode,b.name name_pay_mode,a.charge amount,convert(varchar,a.price_date,120) date_pay,
1 dt_paytype,a.price_opera code_psn_pay,psn.name name_psn_pay,mz_dept_no code_dept_pay
from gh_deposit_b a
left join zd_cheque_type b on a.cheque_type = b.code
left join a_employee_mi psn on psn.code = a.price_opera
--WHERE price_date between ${BEGIN_DATE} and ${END_DATE}
where EXISTS
(
select patient_id,times
from uh_dc_pi_temp t
where t.patient_id=a.patient_id
)

as

union all

select a.sfsb,

select a.patient_id+'_'+cast(a.item_no as varchar+'_'+cast(a.ledger_sn as varchar pk_pay,null pk_dcpv,null pvcode,'SDDYRMYY_G' code_group,'SDDYRMYY' code_org ,
cheque_type code_pay_mode,b.name name_pay_mode,a.charge amount,convert(varchar,a.dcount_date,120) date_pay, 'O' code_pvtype,
case when a.charge>=0 then 5 when a.charge<0 then 2 end dt_paytype,a.dcount_id code_psn_pay,psn.name name_psn_pay,mz_dept_no code_dept_pay
from mz_deposit_c a
left join zd_cheque_type b on a.cheque_type = b.code
left join a_employee_mi psn on psn.code = a.dcount_id
--WHERE a.dcount_date between ${BEGIN_DATE} and ${END_DATE}

wm_concat(a.zdmc) as 诊断 from zjhis.mz_zdxx a

where EXISTS
(
select patient_id,times
from uh_dc_pi_temp t
where t.patient_id=a.patient_id
)
union all
select a.patient_id+'_'+cast(a.item_no as varchar+'_'+cast(a.ledger_sn as varchar pk_pay,'O' code_pvtype,
a.patient_id+'_'+convert(varchar,times) pk_dcpv,a.patient_id+convert(varchar,times) pvcode,'SDDYRMYY_G' code_group,'SDDYRMYY' code_org ,
cheque_type code_pay_mode,b.name name_pay_mode,a.charge amount,convert(varchar,a.price_date,120) date_pay,
1 dt_paytype,a.price_opera code_psn_pay,psn.name name_psn_pay,mz_dept_no code_dept_pay
from gh_deposit_c a
left join zd_cheque_type b on a.cheque_type = b.code
left join a_employee_mi psn on psn.code = a.price_opera
--WHERE price_date between ${BEGIN_DATE} and ${END_DATE}
where EXISTS
(
select patient_id,times
from uh_dc_pi_temp t
where t.patient_id=a.patient_id
)
事情发生早先本身利用的是convert,会冒出‘从数据类型 varchar 调换为 numeric 时出错。错误。改成cast后也是那样。
附:patient_id---char,.item_no--smallint,ledger_sn--smallint.

group by a.sfsb

直白能够接收 wm_concat 函数

本文由云顶集团用户登录发布于新闻动态,转载请注明出处:SQL server 和 Oracle 中列转行的小操作

关键词: