How to fix Error 143 on Windows Server 2025 / Windows 11

Troubleshooting Guide: SQL Server Error 143 — “A COMPUTE BY item was not found in the order by list”

Why This Error Happens

This error occurs because SQL Server’s COMPUTE BY clause requires that every column referenced in the COMPUTE BY list also appear, in the same order, within the query’s ORDER BY clause. When a query is written with a COMPUTE BY expression that references a column absent from ORDER BY — or listed in a mismatched sequence — the SQL Server 2025 query parser rejects the statement before execution. This is not a permissions, port, or corruption issue; it is a strict T-SQL syntax validation rule tied to how COMPUTE BY generates subtotal breaks based on sort order.

Step-by-Step Resolution Guide

Step 1: Identify the Offending Query

  • Open SQL Server Management Studio (SSMS) or Azure Data Studio and locate the exact query returning Error 143.
  • Check the SQL Server error log at C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOG for the timestamp and session ID tied to the failure.
  • Extract the full SELECT ... COMPUTE BY ... statement for review.

Step 2: Align the ORDER BY and COMPUTE BY Clauses

  • Ensure every column listed in COMPUTE BY is also present in ORDER BY, in the exact same left-to-right order.
  • Example fix:
  • Incorrect: ORDER BY CustomerID SELECT ... COMPUTE SUM(Amount) BY Region
  • Corrected: ORDER BY Region, CustomerID SELECT ... COMPUTE SUM(Amount) BY Region
  • Update the query in your application code, stored procedure, or SSMS query window accordingly.

Step 3: Consider Modernizing Deprecated Syntax

  • Note that COMPUTE BY is a deprecated feature retained for backward compatibility in SQL Server 2025.
  • Replace COMPUTE BY logic with GROUP BY combined with ROLLUP, CUBE, or window functions (SUM() OVER (PARTITION BY ...)) for better performance and long-term supportability.
  • Test the rewritten query in a non-production environment first to confirm equivalent output.

Step 4: Redeploy and Re-execute

  • Save the corrected script and redeploy it to the stored procedure, SSIS package, or application layer that originally triggered the error.
  • Restart the SQL Server Agent job (if applicable) via services.msc or sqlcmd -S <ServerName> -Q "EXEC msdb.dbo.sp_start_job N'JobName'" to confirm the fix takes effect.

Alternative or Verification Steps

  • Run the corrected query directly in SSMS against a test database to confirm it executes without Error 143 and returns expected subtotal breaks.
  • If rewriting isn’t immediately feasible, use SET FMTONLY ON (in compatible modes) or a query validation tool to catch COMPUTE BY/ORDER BY mismatches before deployment to production pipelines.