• 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: 3583
16
Android Java
  • 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;
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic