SELECT TOP(@Limit)[Id], [WorkspaceId], [TargetService], [TargetResource], [ActionType], [CapacityDelta], [Confidence], [Reason], [MetricSummary], [RequiresApproval], [Status], [CreatedAtUtc], [LastUpdatedAtUtc], [ApprovedAtUtc], [ApprovedBy], [ExecutedAtUtc], [ExecutionMessage]
FROM [dbo].[AutonomousScalingRecommendations]
WHERE [WorkspaceId] = @WorkspaceId
  AND (@HasStatuses = 0
   OR [Status] IN @Statuses)
  AND (@CreatedAfterUtc IS NULL
   OR [CreatedAtUtc] >= @CreatedAfterUtc)
ORDER BY [CreatedAtUtc] DESC;
