Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Group by ALL

Author  Topic 

MBeal
Posting Yak Master

110 Posts

Posted - 2002-09-23 : 12:49:14
I'm trying to get each of the source codes regardless if there is a value. When I use the Group by All clause the sum returns "null". I would like to replace this with a zero. Any suggestions?

My query is like this...

Select isnull(sc.V1Code, tf.SourceCode) SourceCode,
Sum(isnull(tfc.Calls,0)) "Calls"
From SourceCode sc full outer join TollFree tf
on sc.V1Code = tf.SourceCode left outer join TollFreeCalls tfc
on tfc.TollFreeNum = tf.PhoneNum and
tfc.CallDate between '09/11/2002' and '09/17/2002'
Where tfc.TollFreeNum not in ('XXX-XXX-XXX', 'XXX-XXX-XXX')
Group by All isnull(sc.V1Code, tf.SourceCode)




MBeal

nr
SQLTeam MVY

12543 Posts

Posted - 2002-09-23 : 12:52:02
put an isnull around the sum.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

MBeal
Posting Yak Master

110 Posts

Posted - 2002-09-23 : 13:00:31
I kept on working the problem and came up with the same solution. I also changed my joins a little to make them less "busy".

Thanks!



MBeal
Go to Top of Page
   

- Advertisement -