Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

query problem

Status
Not open for further replies.

koko007

Programmer
Mar 18, 2006
1
US
Hey All,

.. say I had the following query:

select fld_a, sum(fld_b), avg(fld_b) from tbl_ab group by fld_a

and also say that fld_a can take various values, however in the result from the query above I want to combine all "NULL" and "0" values under one category.

Example:
instead of getting as a resulet:
NULL 200 20.0
Hell 120 18.776
0 10 10

I want to get NULL and 0 combined in the same category like this:
NULL 210 18.0
Hell 120 18.776

Any ideas?
 
use COALESCE instead of IFNULL

same result, but it means you won't have to unlearn/relearn the technique should you ever write sql for another database, since COALESCE is standard sql (as far as i know)

:)

r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top