If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Null in case db2 9.1 sql

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-20-12, 09:52
junaid377 junaid377 is offline
Registered User
 
Join Date: Jan 2012
Posts: 40
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 09:58.
Reply With Quote
  #2 (permalink)  
Old 01-20-12, 10:00
tonkuma tonkuma is online now
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,193
Try...
NULLIF(x.column4 , '') AS column4a
Reply With Quote
  #3 (permalink)  
Old 01-20-12, 10:31
junaid377 junaid377 is offline
Registered User
 
Join Date: Jan 2012
Posts: 40
Quote:
Originally Posted by tonkuma View Post
Try...
NULLIF(x.column4 , '') AS column4a
it worked ..Thanks
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On