Re: Null Conversion

From: Mike Withers <M(dot)withers(at)uws(dot)edu(dot)au>
To: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Null Conversion
Date: 2001-08-15 03:56:27
Message-ID: 3.0.32.20010815135626.01b9ba80@sovereign.macarthur.uws.edu.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

At 06:30 PM 8/14/01 -0700, you wrote:
>On Wed, 15 Aug 2001, Mike Withers wrote:
>
>> Can anyone tell me how I might convert a null attribute value into a zero
>> attribute value such that it can be multiplied in a query.
>>
>> In Oracle I could do:
>>
>> sal*12*NVL(COMM, 0) AS "Annual Income"
>>
>> where COMM is an attribute (a salesman commission, in an employes table)
>> which has null values. This allows null commissions for non salesmen to
>> give a zero calculated value. The NVL converts a null into zero.
>
>Try coalesce(COMM, 0)
>
>
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
>
Thanks, this works. Tried the other suggestion:

sal * 12 * CAST(COMM AS float8) AS "Annual Income"

which unfortunately didn't work.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2001-08-15 04:23:24 Re: explain, planner and more..
Previous Message s8854617 2001-08-15 03:48:12 How to create a stand alone plpgsql proc