Simple function

From: MaRCeLO PeReiRA <gandalf_mp(at)yahoo(dot)com(dot)br>
To: pgsql <pgsql-general(at)postgresql(dot)org>
Subject: Simple function
Date: 2004-12-07 17:49:14
Message-ID: 20041207174914.18078.qmail@web52706.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi guys,

I have a table with two integer fields (field1 and
field2)...

I would like to construct a function that perform an
operation with this two fiels (field1 + fields2), and
return the string value "A" if the sum is <20, "B" if
the sum is >=20 or <=50, and finally return "C" if the
sum is >50.

So I would do:

"SELECT id,function() FROM mytable;"

and get rows like these:

001 A
002 A
003 C
004 C
005 C
006 B
...

Could you help me???

Thanks in advance,

See ya,

Marcelo

__________________________________________________
Converse com seus amigos em tempo real com o Yahoo! Messenger
http://br.download.yahoo.com/messenger/

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Guy Rouillier 2004-12-07 18:20:22 Re: Performance tuning on RedHat Enterprise Linux 3
Previous Message Bruno Wolff III 2004-12-07 17:43:55 Re: Fwd: 8.0 vs. 7.4 benchmarks