If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > how to use coalesce?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-26-08, 20:45
homer.favenir homer.favenir is offline
Registered User
 
Join Date: Oct 2007
Location: Manila, Philippines
Posts: 132
how to use coalesce?

hi,
anyone please....
in my formula i have to put coalesce function to each field so that if a field is null it will still continue to compute.
e.g.
Code:
(
  (q.ManHours -
    coalesce(q.OTHrs,0)) -
      coalesce(q.regbreak,0) -
        coalesce(q.regadjustment,0)
) as 'Reg Hrs'
do you know how to simplify coalesce? instead of distributing it on each field.

thanks
__________________
Take Nothing But Pictures;
Leave Nothing But Footprints;
Kill Nothing But Time;
Reply With Quote
  #2 (permalink)  
Old 08-26-08, 23:15
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,606
The Coalesce() function isn't distributive, if that is what you're asking. There may be ways to simplify the expression depending on how you want NULL values treated in each of the steps, but the answer you have now is intuitive to me.

-PatP
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On