基于条件的查询过滤器

Query Filter based on condition

我有这个查询 (SQL Server 2019),我实际上想向它添加一个过滤器以仅显示 IssueStatusID = 1 的项目(此列基于 int 数据类型) 任何人都可以帮助解决这个问题或指出正确的方向吗?

SELECT ID, 
STRING_AGG(TRY_CONVERT(varchar, Issue#, 101)  + ': ' + Notes + CHAR(13) + CHAR(10) + CHAR(13), CHAR(10)) WITHIN GROUP (ORDER BY Issue# DESC) AS IssueNotes 
FROM (SELECT DISTINCT 
    ac4.ID, 
    nd.Notes, 
    nd.Issue#,
    nd.IssueStatusID

FROM dbo.IssueTracking AS nd
    INNER JOIN dbo.StatusUpdates AS ac4 ON ac4.ID = nd.ReleaseTrackerID) AS vNotes
GROUP BY ID;

如下所示添加 WHERE 子句。 WHERE 子句限制返回的数据。

SELECT ID, 
STRING_AGG(TRY_CONVERT(varchar, Issue#, 101)  + ': ' + Notes + CHAR(13) + CHAR(10) + CHAR(13), CHAR(10)) WITHIN GROUP (ORDER BY Issue# DESC) AS IssueNotes 
FROM (SELECT DISTINCT 
    ac4.ID, 
    nd.Notes, 
    nd.Issue#,
    nd.IssueStatusID

FROM dbo.IssueTracking AS nd
    INNER JOIN dbo.StatusUpdates AS ac4 ON ac4.ID = nd.ReleaseTrackerID
    WHERE nd.IssueStatusID = 1
) AS vNotes
GROUP BY ID;