Click here to Skip to main content
15,903,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i trid below script for this:

-- script for creating table
Create table TestSum (
SomeValue INT,
TestId INT,
TestName VARCHAR(20)

);


-- to display zero in place of blank but not working its giving blank
SELECT ISNULL(Sum(SomeValue),0) FROM TestSum group by somevalue,testid;



can anybody help me, its urgent...


Thanks in advance.

--Deepika
Posted
Updated 12-May-11 1:19am
v2

1 solution

It works for me:
SQL
SELECT ISNULL(Sum(iD),0) FROM [myDatabase].[dbo].[myTable] WHERE iD=4
Returns a single row, containing 0 as there are no records with an id of "4". If I remove the WHERE clause, it returns a single row, containing "3" as my table has two records, with iDs "1" and "2"

How are you using this?
 
Share this answer
 
Comments
DeepikaSrivastava 12-May-11 8:14am    
Thanks for answering..
but i want output like
1. use group by clause
2.no row are inserted in table
3. select * from tablename / output- no row selected.
4.then run SELECT ISNULL(Sum(SomeValue),0) FROM TestSum group by somevalue,testid;
this displays blank but i want zero

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