Click here to Skip to main content
15,867,594 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

In sql table i have column where value consists Quarterly or Null value.
I have written a StoreProcedure when passing parameters iam unable to get data of NULL Values.

What I have tried:

Hi,

In sql table i have column where value consists Quarterly or Null value.
I have written a StoreProcedure when passing parameters iam unable to get data of NULL Values.
Posted
Updated 23-Nov-17 18:07pm
Comments
Suvendu Shekhar Giri 23-Nov-17 5:36am    
If your table has NULL values what data are you expecting to get?
Can you share the query?
krishnaraosan 23-Nov-17 6:06am    
YES NULL VALUES ARE THERE .
I WANT QUERY WHEN VALUE IS NULL IT SHOULD SHOW AS mONTHLY or Quarterly in where condition to flter
Suvendu Shekhar Giri 23-Nov-17 6:35am    
Can you share the query you are trying?
krishnaraosan 23-Nov-17 23:52pm    
I have column name frequency where it consists value null and Quarterly

FREQUENCY--Column Name
NULL
Quarterly

Please find the query below.
I want to fetch records for both null value and quarterly.With the below query only null values records are fetched not quaterly

select * from MASTER
where FREQUENCY=(CASE WHEN FREQUENCY IS NULL THEN 'MONTHLY' ELSE 'Quarterly' END)
Suvendu Shekhar Giri 24-Nov-17 0:08am    
Please check my solution if that is what you wanted to have-
My Solution[^]

In SQL NULLs propagate - so if you add a column that contains a NULL, you will get NULL as the total result:
SQL
SELECT 1 + NULL + 2

So if you are performing any aggregate operation on your column, and a NULL value exists, you will get a NULL result.
One way round this is to use ISNULL in your query:
SQL
SELECT SUM(ISNULL(MyColumn, 0)) FROM MyTable
Will treat all NULL values in the column as zero.

If this isn't the problem you are having, then you need to explain in much better detail exactly what you problem is.
 
Share this answer
 
Based on the the query and details you have shared above, I believe you are looking to show "MONTHLY" and "QUARTERLY" in the frequency column of the result. If this is what you need then try following-
SQL
SELECT CASE WHEN FREQUENCY IS NULL THEN 'MONTHLY' ELSE 'Quarterly' END AS FREQ,* 
FROM MASTER


Please let me know if this is not what you wanted.

Thanks :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900