RE: Irritating problem

  • From: "Mark W. Farnham" <mwf@xxxxxxxx>
  • To: <Lee.Robertson@xxxxxxxxxx>, <oracle-l@xxxxxxxxxxxxx>
  • Date: Mon, 7 Nov 2011 22:35:52 -0500

Add up? I'm unclear about what you mean. You're going to get exactly one
value per column per row. From your statement it appears that you mean you
want 'N' for a return value when the columns contains 'One', 'Two', or
'Three' and you want 'Y' for 'Four'. Unless you're trying to mask your
meaning I don't know why you're trying to transfer that meaning via numeric
amounts.

If you mean something different, please explain. Otherwise

select decode(READERSHIP_OFTEN_SATURDAY,
'One','N','Two','N','Three','N','Four','Y','N')  "Reader" from lee;

might be what you're trying to do.

Regards,

mwf

-----Original Message-----
From: oracle-l-bounce@xxxxxxxxxxxxx [mailto:oracle-l-bounce@xxxxxxxxxxxxx]
On Behalf Of Robertson Lee - lerobe
Sent: Monday, November 07, 2011 4:36 PM
To: oracle-l@xxxxxxxxxxxxx
Subject: Irritating problem

Chaps,

Been stuck on a little bit of sql. 

Need to add up some columns with text values in them e.g 'One', 'Two'
etc etc and see if the total is > 0.

Thought I had it working but its not

I am doing 

select CASE WHEN (CASE WHEN READERSHIP_OFTEN_SATURDAY='One' 
                       THEN 0.25 END)+
          (CASE WHEN READERSHIP_OFTEN_SATURDAY='Two' 
                       THEN 0.5 END)+
          (CASE WHEN READERSHIP_OFTEN_SATURDAY='Three' 
                       THEN 0.75 END)+
          (CASE WHEN READERSHIP_OFTEN_SATURDAY='Four' 
                       THEN 1 END) > 0 THEN 'Y' ELSE 'N' END AS Reader
                       FROM lee;

Data is as follows
Two values in table for READERSHIP_OFTEN_SATURDAY One Four

Both values are coming back as N when I would expect an Y.

Any help appreciated, its going to be staring me in the face but its late
and Im tired.

TIA
Lee

***************************************************************************
The information contained in this communication is confidential, is intended
only for the use of the recipient named above, and may be legally
privileged.

If the reader of this message is not the intended recipient, you are hereby
notified that any dissemination, distribution or copying of this
communication is strictly prohibited.

If you have received this communication in error, please resend this
communication to the sender and delete the original message or any copy of
it from your computer system.

Thank You.
****************************************************************************

--
//www.freelists.org/webpage/oracle-l


--
//www.freelists.org/webpage/oracle-l


Other related posts: