반응형

        SELECT

          WD.WD_IDX, WD.WD_NAME, WDM.MEMCNT

        FROM    

          TABLE1 AS WD

          LEFT OUTER JOIN

          (

              SELECT WD_IDX, COUNT(1) AS MEMCNT FROM TABLE1_SUB AS WDM WHERE WDM.WDM_DEL = 0 GROUP BY WD_IDX

          ) AS WDM ON WD.WD_IDX = WDM.WD_IDX

        WHERE    

          WD.WD_YEAR = 2020

  AND WD.WD_DEL = 0

        ORDER BY

          WD.WD_NAME ASC

 

 

        SELECT

          WD.WD_IDX, WD.WD_NAME, (SELECT COUNT(1) FROM TABLE1_SUB WHERE WD_IDX = WD.WD_IDX)

        FROM    

          TABLE1 AS WD

        WHERE    

          WD.WD_YEAR = 2020

        ORDER BY

          WD.WD_NAME ASC

반응형
Posted by Hippalus
,