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.项目代码这个他说未明确定义列,什么意思。
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.项目代码这个他说未明确定义列,什么意思。
解决方案 »
- RedHat 5下Oracle关机再开机就不能连接。
- 求sql语句
- 查询的问题
- 创建表空间时候报错,达人来看看
- 如何用ODP.net(Oracle.DataAccess.Client非System.Data.OracleClient)生成类型化的DataSet?
- ==============PLSQL Developer中的问题==================
- win2003下安装oracle9i问题!急呀!!!
- oracle的安装问题
- ORACLE 面向对象中REF的用法?
- 求解释逻辑standby数据库alert日志频繁报ORA-19815而实际操作系统空间没有使用
- oracle求职
- 64位window中通过excel创建连接oracle的数据源报错
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你Temp_cont5这个表用了两个一样的别名。换个别名。
你这SQL改了也还有其他的一堆问题