By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,601 Members | 1,116 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,601 IT Pros & Developers. It's quick & easy.

SUM with possible NULL values

P: 1
Hi experts,

I have a table:

Expand|Select|Wrap|Line Numbers
  1. cod1      int,
  2. hours1   timestamp,
  3.  
  4. cod2       int,
  5. hours2    timestamp,
  6.  
  7. cod3       int,
  8. hours3    timestamp,
  9.  
How can Hi make the sum of hours (hours1+hours2+hours3) that have the same cod?

Note:
hours1 and hours2 and hours3 can be null

Thank you
May 23 '07 #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 534
... How can Hi make the sum of hours (hours1+hours2+hours3) that have the same cod?
Look at the GROUP BY clause:
http://www.postgresql.org/docs/8.2/s...pressions.html
http://www.postgresql.org/docs/8.2/s...ql-select.html


... Note:
hours1 and hours2 and hours3 can be null
Use the COALESCE conditional expression.

These links should help you, but If you have problems putting it all together let us know.
May 24 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.