'Start with IF statement in Subquery

I need to select rows in a subquery with an IF condition:

DECLARE @VersionNo varchar(30)
SET @VersionNo = 'Hello'
SELECT (
    CASE @VersionNo WHEN 'Hello' 
        THEN (SELECT '22','22') 
        ELSE (SELECT '25','22') 
    END)

But I am getting this error:

Msg 156, Level 15, State 1, Line 4
Incorrect syntax near the keyword 'IF'.

Msg 156, Level 15, State 1, Line 4
Incorrect syntax near the keyword 'Then'.

Msg 156, Level 15, State 1, Line 5
Incorrect syntax near the keyword 'Else'.

Msg 102, Level 15, State 1, Line 5
Incorrect syntax near ')'.

Can anyone help me to resolve this?

Based on the answers, I have changed my query to:

DECLARE @VersionNo varchar(30)
SET @VersionNo = 'Hello'
SELECT (
    CASE @VersionNo WHEN 'Hello' 
        THEN (SELECT '22','22') 
        ELSE (SELECT '25','22') 
    END) 

Now I am getting this error:

Msg 116, Level 16, State 1, Line 4
Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.



Solution 1:[1]

Use CASE WHEN:

declare @VersionNo varchar(30);
Set @VersionNo = 'Hello';

Select CASE WHEN @VersionNo='Hello' Then 'Yes' Else 'No' END AS SomeCol;

Solution 2:[2]

You need to use CASE, you cannot use IF in a select query

select case @VersionNo when 'Hello' 
    then 'Yes' 
    else 'No' 
end

Alternatively, you can do this to run different select queries based on the value of your variable:

IF @VersionNo = 'Hello' 
    SELECT 'Yes'
ELSE
    SELECT 'No'

Solution 3:[3]

Check this one :

DECLARE @VersionNo VARCHAR(30)
SET @VersionNo = 'Hello'
SELECT  CASE @VersionNo
          WHEN 'Hello' THEN '22'
          ELSE '25'
        END ,
        CASE @VersionNo
          WHEN 'Hello' THEN '22'
          ELSE '22'
        END

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 StuartLC
Solution 2
Solution 3 Behrouz Bakhtiari