日期:2014-05-17  浏览次数:21217 次

ORA-00918: 未明确定义列
select c.* from (select a.jzdbm as jzdbm,a.jzzm as jzzm,a.rzrq as rzrq,a.ywzy as ywzy,a.ckfs as ckfs,b.kjdm as kjdm,(nvl(sum(a.jf),0)+nvl(sum(a.df),0)) as sjje,b.kjdm from table1 a,table2 b where a.jzdbm=b.dm and a.rzrq<='20110510' and (a.hdbz='' or a.hdbz is null) group by a.jzdbm,a.jzzm,a.rzrq,a.ywzy,a.ckfs,b.kjdm) c order by c.kjdm


想实现按table2表的kjdm字段排序。

请各位帮忙看看,谢谢

------解决方案--------------------
select 
 a.jzdbm as jzdbm,
 a.jzzm as jzzm,
 a.rzrq as rzrq,
 a.ywzy as ywzy,
 a.ckfs as ckfs,
 b.kjdm as kjdm,
 (nvl(sum(a.jf),0)+nvl(sum(a.df),0)) as sjje
from table1 a,table2 b
where a.jzdbm=b.dm and a.rzrq<='20110510' and a.hdbz is null
group by a.jzdbm,a.jzzm,a.rzrq,a.ywzy,a.ckfs,b.kjdm
order by kjdm