Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2008
    Posts
    13

    Unanswered: default values for NULL records

    Some of my results are coming back as NULL, but the data that's processing them needs to have some value, so I'd like to just return a value of zero when I get a NULL. Is there a was to do this? I've looked at using a case statement but I have not been able to get it to work that way so far.

  2. #2
    Join Date
    Dec 2007
    Location
    London, UK
    Posts
    741
    COALESCE(col,0)

  3. #3
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    Also

    NVL(COL1,0)
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by beilstwh
    Also

    NVL(COL1,0)
    yeah, but COALESCE is standard SQL, so if you learn NVL you will just have to unlearn it when you write SQL for some other database system
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Nov 2008
    Posts
    13
    Thanks, that works great!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •