Return multiple columns (int datatype) inside a CASE expression
If you do not want to return anything (i.e. if you want to omit the row entirely) when the condition is not met, then just do not use CASE, use your condition in the WHERE clause:

WITH
  ...
SELECT
  a.id AS a_id,
  b.id AS b_id
FROM
  ...
WHERE
  ...
  AND (b.id - a.id) &gt; 1
;


If, however, you want to return something (like nulls) in both columns instead and would like to avoid repeating the condition, then you could use OUTER APPLY, but you would probably need to rewrite your comma join to use the explicit join syntax, like this:

WITH
  ...
SELECT
  x.a_id,
  x.b_id
FROM
  cte AS a
  INNER JOIN cte AS b ON b.Rownumber = a.Rownumber + 1
  OUTER APPLY
  (
    SELECT
      a.id AS a_id,
      b.id AS b_id,
    WHERE
      (b.id - a.id) &gt; 1
  ) AS x
;


Alternatively, you could replace the inner join with an outer join in this manner:

WITH
  ...
SELECT
  CASE WHEN b.id IS NOT NULL THEN a.id END AS a_id,
  b.id AS b_id
FROM
  cte AS a
  LEFT JOIN cte AS b ON b.Rownumber = a.Rownumber + 1 AND (b.id - a.id) &gt; 1
;


Note that if you are using SQL Server 2012 or later version, you can avoid the self-join entirely by using the LEAD function:

WITH cte AS
  (
    SELECT
      id = id,
      next_id = LEAD(id) OVER (ORDER BY id ASC
                               ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
    FROM
      dbo.Test
  )
SELECT
  id,
  next_id
FROM
  cte
WHERE
  next_id - id &gt; 1
;