随笔

SELECT  p.* ,
        CASE  WHEN u.tongji IS null THEN 0 ELSE u.tongji END
FROM    dbo.AS_Project AS p
        LEFT JOIN ( SELECT  COUNT(0) AS tongji ,
                            ProjectId
                    FROM    dbo.AS_Url
                    WHERE   ProjectId IN ( SELECT   id
                                           FROM     dbo.AS_Project )
                    GROUP BY ProjectId
                  ) AS u ON p.id = u.ProjectId
posted @ 2011-06-21 14:32  Frida-  阅读(156)  评论(0编辑  收藏  举报