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