Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to get Output has 0 in place of NULL Value



This is the Store Proc
select * from GRPS.dbo.PEChartData
select cast(max(PB12m) as decimal(10,2)) as MaxData , cast( min(PB12m)as decimal(10,2)) as MinData from GRPS.dbo.PEChartData
where convert(datetime,[Price Date],102) > DATEADD(year ,-@iNoYr,GETDATE())
and Code=@code


output-
MaxData	MinData
NULL	NULL


What I have tried:

SELECT ISNULL(myColumn, 0 ) FROM myTable



SELECT ISNULL(cast(max(PB12m) as decimal(10,2)) as MaxData , 0 ) FROM GRPS.dbo.PEChartData


But this is getting Error
Incorrect syntax near the keyword 'as'.


Kindly help
Posted
Updated 28-Mar-17 0:06am
v2

isnull (cast(max(PB12m) as decimal(10,2)),0) as MaxData
 
Share this answer
 
The selection column name is in the wrong place.
Try:
SELECT ISNULL(cast(max(PB12m) as decimal(10,2)), 0 )  AS MaxData FROM GRPS.dbo.PEChartData
 
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