i have a problem with my sql query and dont know how to solve it:

The output table consists of.

```
1. SERIALNR   VARCHAR(26) NOT NULL
2. LP_BASIC   VARCHAR(20) NOT NULL
3. LP_NEW     VARCHAR(20)
4. SCORE      NUMBER(20)  NOT NULL
5. CURRENT_LP VARCHAR(20)

```

The query itself works well and contains no errors.

The **LP\_BASIC** column is always filled whereas the **LP\_NEW** is an optional field.
**CURRENT\_LP** should always display **LP\_NEW** (if is not empty) else **LP\_BASIC** (which is never empty).

The problem is, that the "**ELSE f.LP\_BASIC**"-Part is not working.
It should return the **LP\_BASIC value**, if no **LP\_NEW** record is found but instead it only returns an empty field.

```
SELECT 
  f.SERIALNR,
  f.LP_BASIC,
  f.LP_NEW, 
  f.SCORE,
  CASE
    WHEN
      f.LP_NEW
      IS NOT NULL
        THEN
          f.LP_NEW
    ELSE
      f.LP_BASIC
  END
AS CURRENT_LP 
FROM (
        SELECT 
          SERIALNR, 
          MAX(SCORE) MAX_ID
        FROM 
          EAPS.PS_TC_SM 
        GROUP BY 
          SERIALNR
     ) x 
INNER JOIN 
  EAPS.PS_TC_SM f 
ON 
  f.SERIALNR=
  x.SERIALNR 
AND 
  f.SCORE = 
  x.MAX_ID

```

Any help apreciated.

Thank you in advance.

Rob.

**UPDATE** (solved)

The LP\_NEW column was not null, there was a single space char in it, so the "IS NULL" did not work.