Re: Using expressions w/ DECODE?

From: rich <richard.rubinstein_at_ihsenergy.com>
Date: 2000/08/03
Message-ID: <39892aca$1_at_news.star.co.uk>#1/1


You certainly can use expressions in decode statements though not in the form you describe. Try the following:

select decode(sign(LOGINS-5), -1, 'Low', decode(sign(LOGINS-25), -1, 'Medium', 'High')) from your_table;

Richard

louster_at_my-deja.com wrote in message <8m4v6k$kr7$1_at_nnrp1.deja.com>...
>I'd like to write a sql statement labeling users to my website
>as "active", "frequent" or "power" depending on how many times they've
>logged in. Oracle SQL doesn't have an IF-THEN statement and DECODE
>doesn't let you use expressions (eg. < 5 logins = 'active user',
>5>logins>25 = 'active user', > 25 logins = 'power user'). I was
>thinking of getting 3 result sets and using UNION to combine them but
>the query is very expensive. There has got to be a way to do this. Any
>ideas?
>
>
>Sent via Deja.com http://www.deja.com/
>Before you buy.
Received on Thu Aug 03 2000 - 00:00:00 CEST

Original text of this message