1

I want to find average as

  avg = sum(a*b) / ISNULL( NULLIF (sum(b) , 0) ,1)

where a or b can be 0

Auguste
  • 2,007
  • 2
  • 17
  • 25
user6754
  • 71
  • 1
  • 8
  • It would be helpful if you provided sample data that exhibits the problem, the output that you expect, the output that you're seeing along with the full code that you're using, and tag the actual RDBMS that you're using. Please see: http://stackoverflow.com/help/how-to-ask – Tom H May 26 '16 at 14:43
  • I don't understand your question. Can you provide sample data and a result you expect? – PSVSupporter May 26 '16 at 14:43
  • 1
    Every aggregation function ignores NULL, but not zeros. – dnoeth May 26 '16 at 14:49

0 Answers0