Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2012
    Posts
    82

    Unanswered: Null in case db2 9.1 sql

    I need something like this to work....

    I have a column on which there are blanks spaces in a column instead of null.... I need to create a view on it where I replace all the blank spaces with NULL... I wrote a query like this but it is not working...Any suggestions??


    SELECT
    X.Column1,
    X.Column2,
    X.Column3,
    CASE
    WHEN X.column4= ' '
    THEN NULL
    ELSE X.Column4
    END AS COLUMN4a,
    FROM

    ( SELECT * FROM XYZ; ) AS X
    Last edited by junaid377; 01-20-12 at 10:58.

  2. #2
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    Try...
    NULLIF(x.column4 , '') AS column4a

  3. #3
    Join Date
    Jan 2012
    Posts
    82
    Quote Originally Posted by tonkuma View Post
    Try...
    NULLIF(x.column4 , '') AS column4a
    it worked ..Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •