Use ISNULL()

SELECT ..., SUM(ISNULL(secondary.received,0))
..

This will assign 0 to any rows that don't have a value in that column.

Or don't use an OUTER JOIN :D


----- Original Message ----- 
From: "Tyler Silcox" <[EMAIL PROTECTED]>



Is there a way to grab all the records from one table and sum up all the 
values of a column from another table based on a foreign key?

This is what I'm trying to do:

SELECT primary.primary_id, primary.initiated, primary.completed, 
SUM(secondary.received)
FROM primary LEFT OUTER JOIN secondary 
ON primary.primary_id = secondary.primary_id


______________________________________________________________________
Get Your Own Dedicated Windows 2000 Server
  PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER
  Instant Activation � $99/Month � Free Setup
  http://www.pennyhost.com/redirect.cfm?adcode=coldfusionb
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to