drmrkrch 17 Software Engineer

Another way (older way) to join two oracle tables together with outer join syntax would be to do it the following way.

select c.companyname, sum(nvl(i.sales,0))
from customers c, invoices i 
where c.companyname = i.companyname (+)
group by c.companyname

The (+) syntax goes where you expect the nulls to occur

Majestics commented: I DONT HAVE WORDS..... +4
debasisdas commented: agree +13
drmrkrch 17 Software Engineer

Nvl(sales,0) and nvl(purchase,0) is where you need to change.

drmrkrch 17 Software Engineer

Is this oracle DB? Or someother flavor?

drmrkrch 17 Software Engineer

Use the nvl() function around the sums and remove the having portion of your query. I didn't realize that you were calling the same table twice which is is unnecessary for your query. The nvl function will prevent summing nulls which isn't possible. It will convert nulls trouble zero.

drmrkrch 17 Software Engineer

You will need to do an outer join select all from one table while getting the matches from another. Why are you joining on company name instead of an I'd value? Mark