All Forums Database
Yunfei Zhao 8 posts Joined 08/15
09 Sep 2015
how to get rows with a blank value in a column

I have a data that has customer information. This data is set up by the IT people, and I am merely a user of that data. I want to get all the customers that the SSN is blank. If you print the data out for these customers, you would see that the SSN is blank, or there is nothing on the paper. (In Teradata term, it might be called blank, empty, null, etc, and I am not sure). Can you please tell me how to do it?
The code below is what I use, but I am not sure, can you please take a look, and give me the correct code if mine is wrong:
/*code start*/
SELECT *
FROM TABLE
WHERE SSN =' ' /*There is only one space here, do I need more spaces?*/
or SSN is NULL
ORDER BY SSN
/*code end*/
Thanks
Yunfei

saravanatn 10 posts Joined 07/11
09 Sep 2015

Hi,
Your sql query is correct.  In (IS NULL) keyword space should be removed and it should be ISNULL .  I think one space is enough...

Adeel Chaudhry 773 posts Joined 04/08
09 Sep 2015

You can use something like below:

SELECT *
FROM TABLE
WHERE TRIM(SSN) = '' OR SSN IS NULL

-- If you are stuck at something .... consider it an opportunity to think anew.

Adeel Chaudhry 773 posts Joined 04/08
09 Sep 2015

Also .... Empty string i.e. '' .... is not as same as NULL .... NULL represents absence of any value whereas empty string is a value itself.
 
HTH!

-- If you are stuck at something .... consider it an opportunity to think anew.

Jmeher 6 posts Joined 11/14
11 Sep 2015

1 ques?
 
I have output from a SQL as below:
 
 
COL1     COL2   COL3
NULL     NULL     ABC
NULL     NULL     NULL
DEF       NULL     NULL
 
 
 
and 1 want output as below:
 
COL1     COL2     COL3
DEF                     ABC
 
 
 
 
Any help?
 

saravanatn 10 posts Joined 07/11
11 Sep 2015

 
Hi,
You have to use coalesce function to get the result.
 
Saravanan

You must sign in to leave a comment.