• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

SQL quetsion - how to 'convert' null to zero? (if statement)

 
Ranch Hand
Posts: 755
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all,
quick question: is there a possibility to return the value 0 and not NULL from the db?

example:
Select empl_id, age from myTable

result:
1 NULL
2 55

I would like to have:
1 0
2 55

thanks for any pointers
[ October 08, 2007: Message edited by: Peter Primrose ]
 
Ranch Hand
Posts: 338
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
COALESCE(column_name,0)

Select empl_id, COALESCE(age,0)
from myTable


This will regardless RDBMS.
[ October 08, 2007: Message edited by: Paul Campbell ]
reply
    Bookmark Topic Watch Topic
  • New Topic