• Post Reply Bookmark Topic Watch Topic
  • New Topic

NULLIF problem

 
Jacky Luk
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
DBMS: Derby

How can I make c2.Sales 0 when sum(od.NetSales) is 0,
I don't know where it went wrong, but c2.Sales and c2.LastVisit
show null, or empty in my JTable for some records.
Thanks
Jack
 
K. Tsang
Bartender
Posts: 3610
16
Firefox Browser Java Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't know if Derby DB has the NVL() function but you can always fall back to the case statement

select case when a.sales is null then 0 else a.sales as sales from table;

If using NVL then

select NVL(a.sales, 0) as sales from table;
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!