RE: DECODE or not to DECODE

2003-08-14 Thread Denham Eva
Thanks To all for the support!
I managed to use a combination of thesuggestions which worked great!

Denham

-Original Message-
Sent: Monday, August 04, 2003 4:24 PM
To: Multiple recipients of list ORACLE-L


Hello Listers,

I need some help please,
I am trying to create a DECODE statement, on a date column and looks
something like this, but does not work.
SELECT   COL1,
COL2,
DECODE((SYSDATE - COL_DATE), <= 30, '30_days', NULL) Days30,
DECODE((SYSDATE - COL_DATE), (between 31 and 60), '60 Days',
NULL) Days60,
..
..
FROM ACCOUNT_TBL
WHERE COL = '0'

Obviously, I have worked out that this can not be done. The problem is also
that the server is 7.3.4 and I need to use the code in a view.
Does anyone have any solutions/work arounds for this?
Any help will be appraciated.

TIA
Denham Eva
Oracle DBA


_
This e-mail message has been scanned for Viruses and Content and cleared 
by MailMarshal

For more information please visit www.marshalsoftware.com

_


#
Note:
This message is for the named person's use only.  It may contain
confidential,
proprietary or legally privileged information.  No confidentiality or
privilege
is waived or lost by any mistransmission.  If you receive this message in
error,
please immediately delete it and all copies of it from your system, destroy
any
hard copies of it and notify the sender.  You must not, directly or
indirectly,
use, disclose, distribute, print, or copy any part of this message if you
are not
the intended recipient. TFMC and any of its subsidiaries each reserve
the right to monitor all e-mail communications through its networks.

Any views expressed in this message are those of the individual sender,
except where
the message states otherwise and the sender is authorized to state them to
be the
views of any such entity.

Thank You.
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Denham Eva
  INET: [EMAIL PROTECTED]

Fat City Network Services-- 858-538-5051 http://www.fatcity.com
San Diego, California-- Mailing list and web hosting services
-
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).


_
This e-mail message has been scanned for Viruses and Content and cleared 
by MailMarshal

For more information please visit www.marshalsoftware.com

_

_
This e-mail message has been scanned for Viruses and Content and cleared 
by MailMarshal

For more information please visit www.marshalsoftware.com
_

#
Note:
This message is for the named person's use only.  It may contain confidential,
proprietary or legally privileged information.  No confidentiality or privilege
is waived or lost by any mistransmission.  If you receive this message in error,
please immediately delete it and all copies of it from your system, destroy any
hard copies of it and notify the sender.  You must not, directly or indirectly,
use, disclose, distribute, print, or copy any part of this message if you are not
the intended recipient. TFMC and any of its subsidiaries each reserve
the right to monitor all e-mail communications through its networks.

Any views expressed in this message are those of the individual sender, except where
the message states otherwise and the sender is authorized to state them to be the
views of any such entity.

Thank You.
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Denham Eva
  INET: [EMAIL PROTECTED]

Fat City Network Services-- 858-538-5051 http://www.fatcity.com
San Diego, California-- Mailing list and web hosting services
-
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).


RE: DECODE or not to DECODE

2003-08-04 Thread Lord David
Hmm.  I think this might be better

decode(sign(sysdate - col_date - 31), -1, '30_days', NULL) Days30,
decode(sign(sysdate - col_date - 31), -1, NULL, decode(sign(sysdate -
col_date - 61), -1, '60_days', NULL)) Days60

> -Original Message-
> From: Lord David [mailto:[EMAIL PROTECTED]
> Sent: 04 August 2003 15:39
> To: Multiple recipients of list ORACLE-L
> Subject: RE: DECODE or not to DECODE
> 
> 
> One trick is to use the sign() function...
> 
>   decode(sign(30 - sysdate + col_date), 1, '30_days', NULL),
> 
> Regards
> David Lord
> 
> > -Original Message-
> > From: Denham Eva [mailto:[EMAIL PROTECTED]
> > Sent: 04 August 2003 15:24
> > To: Multiple recipients of list ORACLE-L
> > Subject: DECODE or not to DECODE
> > 
> > 
> > Hello Listers,
> > 
> > I need some help please,
> > I am trying to create a DECODE statement, on a date column and looks
> > something like this, but does not work.
> > SELECT   COL1,
> > COL2,
> > DECODE((SYSDATE - COL_DATE), <= 30, 
> > '30_days', NULL) Days30,
> > DECODE((SYSDATE - COL_DATE), (between 31 and 
> > 60), '60 Days',
> > NULL) Days60,
> > ...
> > ...
> > FROM ACCOUNT_TBL
> > WHERE COL = '0'
> > 
> > Obviously, I have worked out that this can not be done. The 
> > problem is also
> > that the server is 7.3.4 and I need to use the code in a view.
> > Does anyone have any solutions/work arounds for this?
> > Any help will be appraciated.
> > 
> > TIA
> > Denham Eva
> > Oracle DBA
> > 
> > __
> > ___
> > This e-mail message has been scanned for Viruses and Content 
> > and cleared 
> > by MailMarshal
> > 
> > For more information please visit www.marshalsoftware.com
> > __
> > ___
> > 
> > ##
> > ###
> > Note:
> > This message is for the named person's use only.  It may 
> > contain confidential,
> > proprietary or legally privileged information.  No 
> > confidentiality or privilege
> > is waived or lost by any mistransmission.  If you receive 
> > this message in error,
> > please immediately delete it and all copies of it from your 
> > system, destroy any
> > hard copies of it and notify the sender.  You must not, 
> > directly or indirectly,
> > use, disclose, distribute, print, or copy any part of this 
> > message if you are not
> > the intended recipient. TFMC and any of its subsidiaries 
> each reserve
> > the right to monitor all e-mail communications through its networks.
> > 
> > Any views expressed in this message are those of the 
> > individual sender, except where
> > the message states otherwise and the sender is authorized to 
> > state them to be the
> > views of any such entity.
> > 
> > Thank You.
> > -- 
> > Please see the official ORACLE-L FAQ: http://www.orafaq.net
> > -- 
> > Author: Denham Eva
> >   INET: [EMAIL PROTECTED]
> > 
> > Fat City Network Services-- 858-538-5051 http://www.fatcity.com
> > San Diego, California-- Mailing list and web 
> hosting services
> > 
> -
> > To REMOVE yourself from this mailing list, send an E-Mail message
> > to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
> > the message BODY, include a line containing: UNSUB ORACLE-L
> > (or the name of mailing list you want to be removed from).  You may
> > also send the HELP command for other information (like subscribing).
> > 
> 
> 
> *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 
> *** *** *** 
>  This e-mail and its attachments are intended for the
>  author's addressee only and may be confidential. 
> 
>  If they have come to you in error you must take no 
>  action based on them, nor must you copy or show 
>  them to anyone; please reply to this e-mail and  
>  highlight the error. 
> 
>  Please note that this e-mail has been created in the
>  knowledge that Internet e-mail is not a 100% secure 
>  communications medium. We advise that you 
>  understand and observe this lack of security when 
>  e-mailing us. Steps have been 

RE: DECODE or not to DECODE

2003-08-04 Thread Carol Bristow
Eva - 

I dredged this out of some ancient code that I wrote against a 7.2
database.  The inner trunc functions were there to get rid of the time -
I don't remember why the outer trunc function was there at this point
(it was five years ago).  This doesn't get you completely there, but
will hopefully get you started.

Decode
(sign(30-(trunc(trunc(SysDate)-trunc(col_date,
1,'30 days',null)



Carol Bristow
DPRA Inc.
1300 N 17th St Suite 950
Rosslyn, VA 22209
Work: 703-841-8025
Fax: 703-524-9415

-Original Message-
Sent: Monday, August 04, 2003 10:24 AM
To: Multiple recipients of list ORACLE-L

Hello Listers,

I need some help please,
I am trying to create a DECODE statement, on a date column and looks
something like this, but does not work.
SELECT   COL1,
COL2,
DECODE((SYSDATE - COL_DATE), <= 30, '30_days', NULL)
Days30,
DECODE((SYSDATE - COL_DATE), (between 31 and 60), '60
Days',
NULL) Days60,
...
...
FROM ACCOUNT_TBL
WHERE COL = '0'

Obviously, I have worked out that this can not be done. The problem is
also
that the server is 7.3.4 and I need to use the code in a view.
Does anyone have any solutions/work arounds for this?
Any help will be appraciated.

TIA
Denham Eva
Oracle DBA


_
This e-mail message has been scanned for Viruses and Content and cleared

by MailMarshal

For more information please visit www.marshalsoftware.com

_


#
Note:
This message is for the named person's use only.  It may contain
confidential,
proprietary or legally privileged information.  No confidentiality or
privilege
is waived or lost by any mistransmission.  If you receive this message
in error,
please immediately delete it and all copies of it from your system,
destroy any
hard copies of it and notify the sender.  You must not, directly or
indirectly,
use, disclose, distribute, print, or copy any part of this message if
you are not
the intended recipient. TFMC and any of its subsidiaries each reserve
the right to monitor all e-mail communications through its networks.

Any views expressed in this message are those of the individual sender,
except where
the message states otherwise and the sender is authorized to state them
to be the
views of any such entity.

Thank You.
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Denham Eva
  INET: [EMAIL PROTECTED]

Fat City Network Services-- 858-538-5051 http://www.fatcity.com
San Diego, California-- Mailing list and web hosting services
-
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Carol Bristow
  INET: [EMAIL PROTECTED]

Fat City Network Services-- 858-538-5051 http://www.fatcity.com
San Diego, California-- Mailing list and web hosting services
-
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).



Re: DECODE or not to DECODE

2003-08-04 Thread Jonathan Gennick
One possibility that comes to mind is to write a really,
really long DECODE:

DECODE((SYSDATE - COL_DATE), 1, '30_days',
   2, '30_days', 3, '30_days', ... NULL) Days30

But there must be a better possibility. Perhaps use the SIGN
function:

DECODE ( SIGN((SYSDATE - COL_DATE)-30),
   -1, '30_DAYS', 0, '30_DAYS', NULL)

If the difference is 1-29, subtracting 30 will result in a
negative value, and SIGN will return -1. If the difference
is exactly 30, the subtraction will result in 0, and SIGN
will return 0. The only other possible return is 1, for
positive numbers, and I let the default (NULL) handle that
case.

My guess is that you could do something similar for your
second DECODE statement, though the math would get a bit
more complex. I'd have to think a bit longer to work up a
solution, but I'm optimistic that there is one.

Hope this helps.

Best regards,

Jonathan Gennick --- Brighten the corner where you are
http://Gennick.com * 906.387.1698 * mailto:[EMAIL PROTECTED]

Join the Oracle-article list and receive one
article on Oracle technologies per month by 
email. To join, visit http://four.pairlist.net/mailman/listinfo/oracle-article, 
or send email to [EMAIL PROTECTED] and 
include the word "subscribe" in either the subject or body.


Monday, August 4, 2003, 10:24:22 AM, you wrote:
DE> Hello Listers,

DE> I need some help please,
DE> I am trying to create a DECODE statement, on a date column and looks
DE> something like this, but does not work.
DE> SELECT   COL1,
DE> COL2,
DE> DECODE((SYSDATE - COL_DATE), <= 30, '30_days', NULL) Days30,
DE> DECODE((SYSDATE - COL_DATE), (between 31 and 60), '60 Days',
DE> NULL) Days60,
DE> ...
DE> ...
DE> FROM ACCOUNT_TBL
DE> WHERE COL = '0'

DE> Obviously, I have worked out that this can not be done. The problem is also
DE> that the server is 7.3.4 and I need to use the code in a view.
DE> Does anyone have any solutions/work arounds for this?
DE> Any help will be appraciated.

DE> TIA
DE> Denham Eva
DE> Oracle DBA

DE> 
_
DE> This e-mail message has been scanned for Viruses and Content and cleared 
DE> by MailMarshal

DE> For more information please visit www.marshalsoftware.com
DE> 
_

DE> 
#
DE> Note:
DE> This message is for the named person's use only.  It may contain confidential,
DE> proprietary or legally privileged information.  No confidentiality or privilege
DE> is waived or lost by any mistransmission.  If you receive this message in error,
DE> please immediately delete it and all copies of it from your system, destroy any
DE> hard copies of it and notify the sender.  You must not, directly or indirectly,
DE> use, disclose, distribute, print, or copy any part of this message if you are not
DE> the intended recipient. TFMC and any of its subsidiaries each reserve
DE> the right to monitor all e-mail communications through its networks.

DE> Any views expressed in this message are those of the individual sender, except 
where
DE> the message states otherwise and the sender is authorized to state them to be the
DE> views of any such entity.

DE> Thank You.
DE> -- 
DE> Please see the official ORACLE-L FAQ: http://www.orafaq.net

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Jonathan Gennick
  INET: [EMAIL PROTECTED]

Fat City Network Services-- 858-538-5051 http://www.fatcity.com
San Diego, California-- Mailing list and web hosting services
-
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).



RE: DECODE or not to DECODE

2003-08-04 Thread Lord David
One trick is to use the sign() function...

  decode(sign(30 - sysdate + col_date), 1, '30_days', NULL),

Regards
David Lord

> -Original Message-
> From: Denham Eva [mailto:[EMAIL PROTECTED]
> Sent: 04 August 2003 15:24
> To: Multiple recipients of list ORACLE-L
> Subject: DECODE or not to DECODE
> 
> 
> Hello Listers,
> 
> I need some help please,
> I am trying to create a DECODE statement, on a date column and looks
> something like this, but does not work.
> SELECT   COL1,
> COL2,
> DECODE((SYSDATE - COL_DATE), <= 30, 
> '30_days', NULL) Days30,
> DECODE((SYSDATE - COL_DATE), (between 31 and 
> 60), '60 Days',
> NULL) Days60,
> ...
> ...
> FROM ACCOUNT_TBL
> WHERE COL = '0'
> 
> Obviously, I have worked out that this can not be done. The 
> problem is also
> that the server is 7.3.4 and I need to use the code in a view.
> Does anyone have any solutions/work arounds for this?
> Any help will be appraciated.
> 
> TIA
> Denham Eva
> Oracle DBA
> 
> __
> ___
> This e-mail message has been scanned for Viruses and Content 
> and cleared 
> by MailMarshal
> 
> For more information please visit www.marshalsoftware.com
> __
> ___
> 
> ##
> ###
> Note:
> This message is for the named person's use only.  It may 
> contain confidential,
> proprietary or legally privileged information.  No 
> confidentiality or privilege
> is waived or lost by any mistransmission.  If you receive 
> this message in error,
> please immediately delete it and all copies of it from your 
> system, destroy any
> hard copies of it and notify the sender.  You must not, 
> directly or indirectly,
> use, disclose, distribute, print, or copy any part of this 
> message if you are not
> the intended recipient. TFMC and any of its subsidiaries each reserve
> the right to monitor all e-mail communications through its networks.
> 
> Any views expressed in this message are those of the 
> individual sender, except where
> the message states otherwise and the sender is authorized to 
> state them to be the
> views of any such entity.
> 
> Thank You.
> -- 
> Please see the official ORACLE-L FAQ: http://www.orafaq.net
> -- 
> Author: Denham Eva
>   INET: [EMAIL PROTECTED]
> 
> Fat City Network Services-- 858-538-5051 http://www.fatcity.com
> San Diego, California-- Mailing list and web hosting services
> -
> To REMOVE yourself from this mailing list, send an E-Mail message
> to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
> the message BODY, include a line containing: UNSUB ORACLE-L
> (or the name of mailing list you want to be removed from).  You may
> also send the HELP command for other information (like subscribing).
> 


*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 
 This e-mail and its attachments are intended for the
 author's addressee only and may be confidential. 

 If they have come to you in error you must take no 
 action based on them, nor must you copy or show 
 them to anyone; please reply to this e-mail and  
 highlight the error. 

 Please note that this e-mail has been created in the
 knowledge that Internet e-mail is not a 100% secure 
 communications medium. We advise that you 
 understand and observe this lack of security when 
 e-mailing us. Steps have been taken to ensure this 
 e-mail and attachments are free from any virus, but 
 advise the recipient to ensure they are actually virus 
 free. 

 The views, opinions and judgments expressed in this 
 message are solely those of the author. The message 
 contents have not been reviewed or approved by Iron 
 Mountain.

*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Lord David
  INET: [EMAIL PROTECTED]

Fat City Network Services-- 858-538-5051 http://www.fatcity.com
San Diego, California-- Mailing list and web hosting services
-
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).