-6

I want to replace null values in a table but without using a function such as isnull because its dealing with a large amount of data and slowing it down.

everywhere online says isnull and coalesce but is there any way without using such functions. I need this because the query

OPENING_OTHER + OPENING_FEE + OPENING_INT AS TOTAL_BALANCE

If one value is NULL then the total balance is always null

Cheers

Andriy M
  • 76,112
  • 17
  • 94
  • 154
rkyyk
  • 163
  • 2
  • 5
  • 13

1 Answers1

2

No, how can you do something without doing anything?

You could permanenetly replace the NULL values with 0 but that would waste a lot of storage.

Transforming your data in a SELECT statement is not terribley costly if you use built in functions designed for that purpose.


The use of coalesce will be the quickest, most effiecient and expediant way to do this.

coalesce(OPENING_OTHER, 0) + coalesce(OPENING_FEE, 0) + 
    coalesce(OPENING_INT, 0) AS TOTAL_BALANCE

In fact, I'd suggest the actual cost of coalesce is so small that its hard to measure.

Jodrell
  • 34,946
  • 5
  • 87
  • 124