SQL Server If statement assigning values Please see the pseudocode below. Basically what I'm trying to do is write a statement that when an account number contains one of the specified codes it will assign that Level to the entire account not to just that one row.    

I've tried using a case statement in a CTE and few other options and I'm not having much luck. Any help is appreciated. 

if AcctNo contains Code = '1' 
then level = '1'
elif AcctNo contains Code = '2'
then level = '2'


AcctNo  Code  charge   level
1       2       50     Null
1       17      60     Null
1       28      61     Null
1       36      62     Null
1       18      63     Null


Desired Results

 AcctNo  Code  charge    level
    1       2       50     2
    1       17      60     2
    1       28      61     2
    1       36      62     2
    1       18      63     2
At a really basic level it would look like this

UPDATE TableName
SET [level] = CASE WHEN AcctNo = '1' THEN '1'
                    WHEN AcctNo = '2' THEN '2'
                    ELSE 'DefaultVal' END


or 

UPDATE TableName
SET [level] = CASE AcctNo WHEN '1' THEN '1'
                    WHEN '2' THEN '2'
                    ELSE 'DefaultVal' END


Depending on if you only need the one column in your conditions or if it's more complicated than that.

Edit  On looking at your expected data it looks like what you want is this:

WITH Levels AS (SELECT AcctNo, Level, 
        MIN(CASE WHEN code IN (1,2,3,4,5) THEN code ELSE NULL END) 
                OVER (PARTITION BY AcctNo) AS MinCode
        FROM Test)
UPDATE Levels
SET level = MinCode


Note: This assumes that you want the minimum code for a given AcctNo.

If you just want a select statement to test then change it to this:

WITH Levels AS (SELECT AcctNo, Code, Charge, Level, 
        MIN(CASE WHEN code IN (1,2,3,4,5) THEN code ELSE NULL END) 
                OVER (PARTITION BY AcctNo) AS MinCode
        FROM Test)
SELECT * FROM Levels