0

次のようなビューを作成するとします。

    CREATE VIEW LOGICTESTVIEW
    AS
    SELECT /*+ PARALLEL */

    t1.CSCD_NM             
    ,CAST (t1.BTS_ID AS VARCHAR (7)) BTS_ID
    ,trunc(t1.D_DTM, 'DD') D_DTM
    ,sum(t1.V_IVHHO_ATT_CNT) V_IVHHO_ATT_CNT
    ,sum(t1.V_T1_BHL_BLK_CNT) V_T1_BHL_BLK_CNT

    FROM DS3R_FH_1XRTT_BTS_LVL_KPI t1

    LEFT OUTER JOIN DMSN.SITES_GEO_HIERARCHY t2
    ON     
    CAST (t1.BTS_ID AS VARCHAR (7)) = t2.BTS_ID
    AND t1.CSCD_NM = t2.CSCD_NM

    LEFT OUTER JOIN DMSN.SITES_SYS_HIERARCHY t3
    ON     
    CAST (t1.BTS_ID AS VARCHAR (7)) = t3.BTS_ID
    AND t1.CSCD_NM = t3.CSCD_NM


    LEFT JOIN (
                SELECT /*+ PARALLEL */
                distinct
                t1.CSCD_NM             
                ,CAST (t1.BTS_ID AS VARCHAR (7)) BTS_ID


                FROM DS3R_FH_EVDO_BTS_LVL_KPI t1

                INNER JOIN (SELECT DISTINCT BTS_ID, CSCD_NM

                        FROM(


                            SELECT /*+ PARALLEL */

                            t1.CSCD_NM             
                            ,CAST (t1.BTS_ID AS VARCHAR (7)) BTS_ID
                            ,trunc(t1.D_DTM, 'DD') D_DTM
                            ,sum(t1.V_IVHHO_ATT_CNT) V_IVHHO_ATT_CNT
                            ,sum(t1.V_T1_BHL_BLK_CNT) V_T1_BHL_BLK_CNT
                            --,sum(t4.BACKHAUL_BLK_CNT) BACKHAUL_BLK_CNT

                            FROM DS3R_FH_1XRTT_BTS_LVL_KPI t1

                            LEFT OUTER JOIN DMSN.SITES_GEO_HIERARCHY t2
                            ON     
                            CAST (t1.BTS_ID AS VARCHAR (7)) = t2.BTS_ID
                            AND t1.CSCD_NM = t2.CSCD_NM

                            LEFT OUTER JOIN DMSN.SITES_SYS_HIERARCHY t3
                            ON     
                            CAST (t1.BTS_ID AS VARCHAR (7)) = t3.BTS_ID
                            AND t1.CSCD_NM = t3.CSCD_NM

                            WHERE (trunc(t1.D_DTM, 'DD') BETWEEN to_date('8/28/2013', 'mm/dd/yyyy') and to_date('9/3/2013', 'mm/dd/yyyy')) AND t2.MRKT_NM = 'East Iowa'

                            GROUP BY 
                            t1.CSCD_NM
                            ,t1.BTS_ID
                            ,trunc(t1.D_DTM, 'DD')

                            HAVING sum(t1.V_IVHHO_ATT_CNT) > 50    

                        )

                        ) t4
                ON
                CAST (T1.BTS_ID AS VARCHAR (7)) = T4.BTS_ID
                AND T1.CSCD_NM = T4.CSCD_NM

                INNER JOIN DMSN.SITES_GEO_HIERARCHY t2
                ON     
                CAST (t1.BTS_ID AS VARCHAR (7)) = t2.BTS_ID
                AND t1.CSCD_NM = t2.CSCD_NM

                WHERE (trunc(t1.D_DTM, 'DD') BETWEEN to_date('8/28/2013', 'mm/dd/yyyy') and to_date('9/3/2013', 'mm/dd/yyyy')) AND t2.MRKT_NM = 'East Iowa'

                GROUP BY
                t1.CSCD_NM
                ,CAST (t1.BTS_ID AS VARCHAR (7))
                ,trunc(t1.D_DTM, 'DD')

                HAVING
                sum(t1.BACKHAUL_BLK_CNT) > 100
                ) t4
    ON
    CAST (T1.BTS_ID AS VARCHAR (7)) = T4.BTS_ID
    AND T1.CSCD_NM = T4.CSCD_NM

    WHERE (trunc(t1.D_DTM, 'DD') BETWEEN to_date('8/28/2013', 'mm/dd/yyyy') and to_date('9/3/2013', 'mm/dd/yyyy')) AND t2.MRKT_NM = 'East Iowa' AND t4.CSCD_NM IS NULL

    GROUP BY
    t1.CSCD_NM
    ,t1.BTS_ID
    ,trunc(t1.D_DTM, 'DD')

    HAVING sum(t1.V_IVHHO_ATT_CNT) > 50

ビュースクリプトのwhere句にハードコーディングする代わりに、ビュー句のwhere条件にあるものをビュースクリプトに戻すことは可能ですか?

だから私はこれを照会します:

    SELECT * 
    FROM
    LOGICTESTVIEW
    WHERE (trunc(tD_DTM, 'DD') BETWEEN to_date('8/28/2013', 'mm/dd/yyyy') and to_date('9/3/2013', 'mm/dd/yyyy')) AND MRKT_NM = 'East Iowa'

WHERE 句をビュー スクリプトのそれらの場所に戻します。このようにして、ユーザーは独自の開始データと終了データ、および MRKT 名を照会できます。

4

0 に答える 0