我的任務是將舊報表程序轉換爲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