Skip site navigation (1) Skip section navigation (2)

DECODE

From: David Link <dlink(at)soundscan(dot)com>
To: "pgsql-novice(at)postgresql(dot)org" <pgsql-novice(at)postgresql(dot)org>
Subject: DECODE
Date: 2001-10-30 22:41:47
Message-ID: 3BDF2CAB.A16463F9@soundscan.com (view raw or flat)
Thread:
Lists: pgsql-novice
Hi,

How does one do the equivalence of Oracle's DECODE in PostgreSQL?

select 
  decode (v.media, 'V', 'VHS', 'L', 'Laser Disk', 'Unknown')
from
  videos v
; 

(ie. if (v.media == 'V') return 'VHS'; 
     elsif (v.media == 'L') return 'Laser Disk';
     else  return 'Unknown'; )

thanks 
dlink

Responses

  • Re: DECODE at 2001-10-31 01:15:26 from Josh Berkus

pgsql-novice by date

Next:From: Josh BerkusDate: 2001-10-31 01:15:26
Subject: Re: DECODE
Previous:From: Jason WongDate: 2001-10-30 16:49:27
Subject: Re: Problems connecting from pgAdmin II v1.1 build 59

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group