DECLARE
@RowLimit INT = IIF(@Limit IS NULL OR @Limit <= 0, 200, @Limit);

SELECT *
FROM [dbo].[KnowledgeAdaptationTelemetryRecords]
WHERE [WorkspaceId] = @WorkspaceId
  AND (@Source IS NULL
   OR [Source] = @Source)
  AND (@ClassificationTag IS NULL
   OR [ClassificationTag] = @ClassificationTag)
  AND (@OccurredAfter IS NULL
   OR [OccurredAt] >= @OccurredAfter)
ORDER BY [OccurredAt] DESC, [RecordedAt] DESC
OFFSET 0 ROWS FETCH NEXT @RowLimit ROWS ONLY;
