select sum(sumnums) from ( select count(a.*) sumNums from a where a.editor='zhang' and a.issue_time between starttime and endtime union select count(b.*) sumNums from b where b.editor='zhang' and b.issue_time between starttime and endtime )
select count(*) from ( select * from A where editor='zhang' and issue_time between starttime and endtime union select * from B where editor='zhang' adn issue_time bewteen starttime and endtime )
好象不行呀急!我在jsp中调用oracle! if (mysub!=null) { String starttime=request.getParameter("bgtime"); String endtime=request.getParameter("ovtime"); String userid=request.getParameter("userid"); String mysql="select sum(sumNums) from (select count(platform_paper.*) sumNums from platform_paper where platform_paper.editor='"+userid+"' and platform_paper.issue_time between to_date('"+starttime+"','yyyy-mm-dd hh24:mi:ss') and to_date('"+endtime+"','yyyy-mm-dd hh24:mi:ss') union select count(platform_newpage.*) sumNums from platform_newpage where platform_newpage.editor='"+userid+"' and platform_newpage.issue_time between to_date('"+starttime+"','yyyy-mm-dd hh24:mi:ss') and to_date('"+endtime+"','yyyy-mm-dd hh24:mi:ss'))"; out.println(mysql); ResultSet rm=mybeans.executeQuery(mysql); if (rm.next()) {out.print(rm.getString("sumnums")); } mybeans.close(); } // starttime的格式是这样的:starttime="2002-12-9"因此我用了一个转换函数! sumnums与sumNums有没有关系呢? 取值是否这样取:rm.getString("sumnums"); ---------------------- 希望帮人帮到底,送佛送上天!
Select sum(count_num) from( Select count(*) count_num from A where A.editor='zhang' and A.issue_time >=begin_time and A.issue_time <=end_time union Select count(*) count_num from B where B.editor='zhang' and B.issue_time >=begin_time and B.issue_time <=end_time )
检查你的 out.println(mysql); 输出的结果,放到oracle中执行一下
修改以下:Select sum(count_num) connum from( Select count(*) count_num from A union Select count(*) count_num from B ) C where C.editor='zhang' and (C.issue_time between begin_time and end_time)
select count(*) from ( select * from A UNION ALL select * from B ) c where c.editor='zhang' and c.issue_time >=begin_time and c.issue_time <=end_time
out.print(rm.getString("sumnums"));sumnums不是一个字段,那可以执行吗? 修改为: String mysql="select sum(sumNums) connum from ..... .... out.print(rm.getString("connum"));
sqlplus提示:platform_paper.*无效的列
你用了我那个没有Select sum(C.count_num) connum from( Select count(*) count_num from A union Select count(*) count_num from B ) C where C.editor='zhang' and (C.issue_time between begin_time and end_time)..... String mysql="select sum(C.count_num) connum from .......
union 有问题,会剔除重复记录 要用的话也要用union all
sorry,无效的列Select sum(C.count_num) connum from( Select count(*) count_num,a.* from A union Select count(*) count_num,b.* from B ) C where C.editor='zhang' and (C.issue_time between begin_time and end_time);
(
select count(a.*) sumNums
from a
where a.editor='zhang'
and a.issue_time between starttime and endtime
union
select count(b.*) sumNums
from b
where b.editor='zhang'
and b.issue_time between starttime and endtime
)
(
select * from A where editor='zhang' and issue_time between
starttime and endtime
union
select * from B where editor='zhang' adn issue_time bewteen
starttime and endtime
)
if (mysub!=null)
{
String starttime=request.getParameter("bgtime");
String endtime=request.getParameter("ovtime");
String userid=request.getParameter("userid");
String mysql="select sum(sumNums) from
(select count(platform_paper.*) sumNums from
platform_paper where
platform_paper.editor='"+userid+"' and
platform_paper.issue_time between
to_date('"+starttime+"','yyyy-mm-dd hh24:mi:ss')
and to_date('"+endtime+"','yyyy-mm-dd hh24:mi:ss')
union select count(platform_newpage.*)
sumNums
from platform_newpage where
platform_newpage.editor='"+userid+"'
and platform_newpage.issue_time
between to_date('"+starttime+"','yyyy-mm-dd hh24:mi:ss')
and to_date('"+endtime+"','yyyy-mm-dd hh24:mi:ss'))";
out.println(mysql);
ResultSet rm=mybeans.executeQuery(mysql);
if (rm.next())
{out.print(rm.getString("sumnums"));
}
mybeans.close();
}
//
starttime的格式是这样的:starttime="2002-12-9"因此我用了一个转换函数!
sumnums与sumNums有没有关系呢?
取值是否这样取:rm.getString("sumnums");
----------------------
希望帮人帮到底,送佛送上天!
from(
Select count(*) count_num
from A
where A.editor='zhang'
and A.issue_time >=begin_time
and A.issue_time <=end_time
union
Select count(*) count_num
from B
where B.editor='zhang'
and B.issue_time >=begin_time
and B.issue_time <=end_time
)
out.println(mysql); 输出的结果,放到oracle中执行一下
from(
Select count(*) count_num
from A
union
Select count(*) count_num
from B
) C
where C.editor='zhang' and (C.issue_time between begin_time and end_time)
select * from A
UNION ALL
select * from B
) c
where c.editor='zhang'
and c.issue_time >=begin_time
and c.issue_time <=end_time
修改为:
String mysql="select sum(sumNums) connum from
.....
....
out.print(rm.getString("connum"));
from(
Select count(*) count_num
from A
union
Select count(*) count_num
from B
) C
where C.editor='zhang' and (C.issue_time between begin_time and end_time).....
String mysql="select sum(C.count_num) connum from
.......
要用的话也要用union all
from(
Select count(*) count_num,a.*
from A
union
Select count(*) count_num,b.*
from B
) C
where C.editor='zhang' and (C.issue_time between begin_time and end_time);