SELECT te.[Id],
       te.[ExecutionMode],
       te.[WorkKind],
       te.[ExecutionType],
       te.[AssignedAgent],
       te.[QueuedAt],
       te.[StartedAt],
       te.[FinishedAt],
       te.[Status],
       te.[InputDataJson],
       te.[OutputDataJson],
       te.[OutputDataRef],
       te.[ErrorMessage],
       te.[CorrelationId],
       te.[ReplayedFromTaskId],
       te.[WorkspaceId],
       te.[AssignmentType],
       te.[ConfidenceScore],
       te.[RetryCount],
       te.[LastRetryAt],
       te.[MaxRetryAttempts],
       te.[RetryReason],
       te.[Priority],
       te.[RetryOfTaskId],
       te.[SuggestionLogId],
       te.[CreatedAt],
       te.[SuggestedPatchJson],
       te.[AiReviewEvidenceManifestJson],
       te.[AiReviewStatus],
       te.[CreatedVia],
       te.[Language], te.[Domain], te.[RepositoryUrl], te.[Branch], te.[FilePath], te.[Prompt], te.[OutputFormat], te.[TriggerSource], te.[ExternalId], te.[ExternalSystem], te.[RowVersion], tr.[Id] AS ReviewSplit, tr.[Id], tr.[TaskExecutionId], tr.[ReviewerEmail], tr.[ReviewerId], tr.[Decision], tr.[Feedback], tr.[RequestedAt], tr.[RespondedAt], tr.[RespondedBy], tr.[ExpectedSlaDuration], tr.[SlaViolatedAt], tr.[IsLate], tr.[IsOverdue], tr.[ReviewerDisplayName], tr.[RespondedByDisplayName], tr.[IsHelpful], tr.[Flags], tr.[SuggestedPrompt], tr.[StrategyId], tr.[StrategyRating], tr.[StrategyComment]
FROM [dbo].[TaskExecutions] te
    LEFT JOIN [dbo].[TaskReviews] tr
ON tr.[TaskExecutionId] = te.[Id]
WHERE te.[Id] = @Id;
