select t.專案代碼,t.專案名稱,t.我院單價,t.二級醫院單價,sum(t.數量),sum(t.金額) from (
select '門診' 地點,
a.item_id 專案代碼,
a.item_cnname 專案名稱,
a.item_std 單位,
a.rprice 我院單價,
c.je_a 二級醫院單價,
sum(a.quantity) 數量,
sum(a.sum_total) 金額
from op.op_charge a left join Temp_cont5 c on a.item_id=c.dm_a left join Temp_cont5 c on a.item_id=c.dm_a, op.op_chgnote b
where a.chgnote_id = b.chgnote_id
and a.logcdate >= to_date('20150101', 'yyyymmdd')
and a.logcdate < to_date('20150111', 'yyyymmdd') + 1
and b.csreport_id <> 'NONE'
and b.ssubsys_id = '68'
and a.medcatype_id not in ('P17', 'P21', 'P22', 'P23')
group by a.item_id, a.item_cnname, a.item_std, a.rprice,c.je_a
union
select '住院' 地點,
a.xmdm 專案代碼,
a.xmmc 專案名稱,
a.danwei 單位,
b.rprice_op 我院單價,
c.je_a 二級醫院單價,
sum(a.xmsl) 數量,
sum(a.jine) 金額
from ndns.mx a left join Temp_cont5 c on a.xmdm=c.dm_a left join Temp_cont5 d on a.xmdm=c.dm_a, hthis.p_item b
where a.xmdm = b.item_id
and a.fsrq >= to_date('20150101', 'yyyymmdd')
and a.fsrq < to_date('20150111', 'yyyymmdd') + 1
and a.hsfl not in ('P17', 'P21', 'P22', 'P23')
group by a.xmdm, a.xmmc, a.danwei, b.rprice_op,c.je_a) t
group by t.專案代碼,t.專案名稱,t.我院單價,t.二級醫院單價
order by t.專案代碼
這個他說未明確定義列,什么意思。
uj5u.com熱心網友回復:
列名拼寫錯誤或者表.列參考錯誤(即,參考了表中不存在的列)uj5u.com熱心網友回復:
報 未明確定義列是因為uj5u.com熱心網友回復:
from op.op_charge aleft join Temp_cont5 c on a.item_id = c.dm_a
left join Temp_cont5 c on a.item_id = c.dm_a, op.op_chgnote b
你Temp_cont5這個表用了兩個一樣的別名。換個別名。
你這SQL改了也還有其他的一堆問題
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/89177.html
標籤:基礎和管理
下一篇:咨詢關于磁區索引的問題
