从Authors表开始,然后左向外部联接到documents表。这意味着您需要将条件移动到外部联接中。
SELECt [AuthorID] As "Author ID",RTRIm([AuthorFirstName]) + ' ' + RTRIm([AuthorLastName]) AS "Author", COUNT(document.ID) AS "Number of Docs Authored"FROM Author a LEFT OUTER JOIN document d on d.AuthorID = a.ID AND [CompletedStatus] = 'Yes' AND [CompletedOn] >= DATEADD(d, -365, getdate())WHERe a.ID IN (<list of author ID's>)GROUP BY a.[ID], [AuthorFirstName], [AuthorLastName]ORDER BY [Number of Docs Signed] DESC
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)