0

以下に質問があります。これはサブクエリを実行する正しい方法ですか?

SELECT App.State_Pstl_Name,
       COUNT (DISTINCT App.APLCTN_ID) AS Total_APLCTN
FROM (Select count(distinct b.APLCTN_ID ),
             A.Aplctn_Sk,
             b.APLCTN_ID,
             A.Lctn_Sk,  
             b.APLCTN_CREATD_DT,
             B.Aplctn_Sbmtd_Dt,
             c.STATE_PSTL_CD,
             c.STATE_PSTL_NAME,
             C.Urbn_Rrl_Ind
      From  MIDAS.Ee_Application_Mmbr_Fact A,
            MIDAS.Insrnc_Aplctn_Dmnsn B,
            Midas.Lctn_Dmnsn C
      Where A.Lctn_Sk In (Select Lctn_Sk
                            From  Midas.Lctn_Dmnsn
                            Where Flag_Actv_Rec = 'Y' ) And
            A.Aplctn_Sk in (select Aplctn_Sk
                              from MIDAS.Insrnc_Aplctn_Dmnsn
                              Where Flag_Actv_Rec = 'Y' ) AND
            (b.APLCTN_CREATD_DT >= '01-JUL-13' OR
             b.APLCTN_CREATD_DT <= '01-JUL-31' ) 
     GROUP BY A.Aplctn_Sk,
              b.APLCTN_ID,
              a.LCTN_SK,
              b.APLCTN_CREATD_DT,
              B.Aplctn_Sbmtd_Dt,
              c.STATE_PSTL_CD,
              c.STATE_PSTL_NAME,
              c.URBN_RRL_IND) App
GROUP BY App.STATE_PSTL_NAME
Order By App.State_Pstl_Name
4

0 に答える 0