2

I am attempting to get the greatest value from this part of a query:

greatest((follette_title.usedbuying_price *1.37) or 
         (amtext.price*1.37) or 
         (nebraska.price *1.2) or 
         (tichenor.price *1.25))

My issue is there are null values in the tables, so this only returns null. How do I get around this without running an update on all the tables to change the null values to 0?

4

2 に答える 2

1

私はあなたが意味すると仮定します:

greatest((follette_title.usedbuying_price *1.37),
         (amtext.price*1.37),
         (nebraska.price *1.2),
         (tichenor.price *1.25)
        )

orこの文脈ではあまり意味がありません。

すべての価格が 0 より大きいと仮定すると、次の場合にそれらを 0 に変換できますNULL

greatest(coalesce((follette_title.usedbuying_price *1.37, 0),
         coalesce((amtext.price*1.37, 0),
         coalesce((nebraska.price *1.2, 0),
         coalesce(tichenor.price *1.25, 0)
       )
于 2013-08-30T18:10:43.710 に答える