Search This Blog

Monday, February 11, 2013

Aggrigate function SUM return NULL manage by isnull, CALESCE.


Aggrigate function SUM return NULL manage by isnull, CALESCE.


select SUM(fileno) as filedata, SUM(addno) as addre from formA1 where userid=2
 

select SUM(isnull(fileno,0)) as filedata, SUM(isnull(addno,0)) as addre from  (SELECT NULL AS fileno,NULL as addno) formA1

SELECT SUM(fileno) FROM (SELECT  COALESCE(NULL,0)AS fileno)formA1   
OUTPUT:
 

No comments :