Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > Oracle
| Search | Today's Posts | Mark Forums Read
Oracle General Oracle database discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Oracle section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 7th, 2011, 08:34 AM
Registered User
 
Join Date: Jan 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Or in a Case after where

Hi all,

I'm trying to display values of the last 3 month before this.

So i tried it with a case like:

Code:
...
AND "MONTH" = CASE

WHEN to_char(add_months(trunc(sysdate,'MM'),-1),'MM') = '12' THEN '10' OR '11' OR '12'
WHEN to_char(add_months(trunc(sysdate,'MM'),-1),'MM') = '01' THEN '11'  OR '12' OR '01'
...
END
The Problem is, it just won't work with the "or"s within the case. If I just take "...THEN '10' " it works perfectly, but i need it to be the three values. How can i solve that problem?
 
Old February 28th, 2011, 04:13 AM
Authorized User
Points: 350, Level: 6
Points: 350, Level: 6 Points: 350, Level: 6 Points: 350, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2008
Location: , , Pakistan.
Posts: 54
Thanks: 8
Thanked 1 Time in 1 Post
Default It might help

*-*-* AND/OR *-*-*

The AND operator displays a record if both the first condition and the second condition is true.
p q p AND q
T T T
T F F
F T F
F F F
The OR operator displays a record if either the first condition or the second condition is true.
p q p OR q
T T T
T F T
F T T
F F F
SELECT CUST
FROM tblcust
WHERE cust > 6110148910985
OR (cust < 8 AND cust > 6)
*-*-*-*
try using brackets:

WHEN to_char(add_months(trunc(sysdate,'MM'),-1),'MM') = ('12' THEN '10') OR ('11' OR '12')
__________________
How to do programming?




Similar Threads
Thread Thread Starter Forum Replies Last Post
how to use OR operator or CASE?? jcarswelljr SQL Language 8 February 16th, 2009 10:00 PM
Case help michael.boucher SQL Server 2005 0 May 23rd, 2008 01:45 AM
select case yuvalk SQL Server 2000 4 August 25th, 2004 02:33 PM
search string either Upper case or lower case rylemer Beginning VB 6 3 March 24th, 2004 04:23 PM
Check Case in a Case-Insensitive DB nbryson SQL Language 1 January 23rd, 2004 07:36 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.