所以我有2个查询,其中一个是使用第一个查询中的值的子查询。我需要将它变成1个查询,以便我可以将它们作为视图。所以第一个查询是,
SELECT LEVEL WEEK_NUM_INCR,
TO_CHAR (start_date + (LEVEL - 1) * 7, 'DD-MON-YYYY') START_WEEK_DATE,
TO_CHAR (start_date + (LEVEL) * 7, 'DD-MON-YYYY') END_WEEK_DATE
FROM (SELECT PS.PROJECT_START_DT start_date,
PS.JOB_NAME JOB_NAME,
PS.PROJECT_END_DT end_date
FROM PROJECT_SPAN PS
WHERE PS.JOB_NAME = :JOBNAME) RS
CONNECT BY start_date + (LEVEL - 1) * 7 < end_date;
,第二个查询是,
SELECT SUM (DO.ONSITE_UPD_QTY) ONSITESUM,
SUM (DO.ONSITE_UPD_QTY * MD.WEIGHT) TOTALONSITEWEIGHT,
FROM PROJECT P
LEFT OUTER JOIN DTL_ERC_UPD@WELTES_SITEMON_LINK DO
ON DO.PROJECT_NAME = P.PROJECT_NAME
LEFT OUTER JOIN MASTER_DRAWING MD ON MD.HEAD_MARK = DO.HEAD_MARK
WHERE DO.UPD_DATE BETWEEN TO_DATE (:STARTDATE, 'DD-MON-YYYY')
AND TO_DATE (:ENDDATE, 'DD-MON-YYYY')
AND P.PROJECT_NO = :PROJNO
GROUP BY P.PROJECT_NO;
第二个查询使用第一个查询START_WEEK_DATE和END_WEEK_DATE中的值:STARTDATE和:ENDDATE作为第一个查询中特定日期范围的范围值。
因此可以在http://pastie.org/9938791中看到php中的整个方法 但是将它们组合在一起并在JSON中分配值是不可能的。请帮我组合这两个查询..我真的很感激
答案 0 :(得分:1)
您可以使用WITH-Clause将第一个查询用作子查询:
http://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_10002.htm
WITH JOBNAME AS (1stQuery)
SELECT-CLAUSE USING JOBNAME as Inlineview (in the FROM-Condition).