我的任务是将旧报表程序转换为Oracle报表,当我需要加入两个查询以使报表生效时,我停下脚步。我不是SQL新手,但我确实需要帮助。SQL查询:如何在Oracle报表中加入两个SQL查询
对于Oracle Reports 11g,报表需要显示以下两个查询的结果,因此需要将这些查询连接到一个SQL查询中才能使报表生效。
首先查询:
select table_name
, to_char(load_date, 'MM/DD/ YYYY') as XDATE
, to_char(number_name) as NUMBER NAME
, round(sysdate-load_date) as DAYS
, 'E' AS TABLEIND
from error_table
where load_date is not null
and round(sysdate-load_date) > 15
and number_name not in
(select number_name
from table_comments)
order by table_name
第二个查询:
select table_name
, to_char(load_date, 'MM/DD/ YYYY') as XDATE
, to_char(number_name) as NUMBER NAME
, round(sysdate-load_date) as DAYS
, 'O' AS TABLEIND
from other_table
where load_date is not null
and round(sysdate-load_date) > 15
and number_name not in
(select number_name
from table_comments)
order by table_name
这两个查询的结果应该显示这两个查询与第一查询第一的结果,而第二查询第二。任何有关这个问题的帮助,高度赞赏。
或联合声明中也许 – asawyer 2011-03-23 18:46:38
如果您使用的联盟,你必须确保不消除重复行,但肯定会工作。我相信 – 2011-03-23 18:51:40
UNION默认情况下消除了愚弄。但是,也许在个别已有的查询中除了*之外不会有任何的*。 – Tim 2011-03-23 18:52:43