Home » SQL & PL/SQL » SQL & PL/SQL » Conditional Selection
Conditional Selection [message #244041] Mon, 11 June 2007 07:16 Go to next message
toastmax
Messages: 16
Registered: November 2006
Junior Member
Hi there

I am having a go at conditional selection criteria but have hit a brickwall.

The query is designed to bring back results depending on the day it is ran.

Here is the statement

select c.email 
from contacts c
where
c.email is not null
and
(case when to_char(sysdate, 'D') in ('3','4','5','6') then (
c.cat = 't' and c.internal 't' and c.private = 'y') 
when to_char(sysdate, 'D') = 2 then 
c.all = 'y
end) 


I keep getting a missing right parenthesis at 'c.cat' = 't'.

Any ideas?
Re: Conditional Selection [message #244044 is a reply to message #244041] Mon, 11 June 2007 07:54 Go to previous messageGo to next message
techno
Messages: 44
Registered: October 2003
Member
You can use UNION for this

Try with this

select c.email 
from contacts c
where
	 c.email is not null
	 and to_char(sysdate, 'D') in ('3','4','5','6') 
	 and c.cat = 't' 
	 and c.internal 't' 
	 and c.private = 'y'
union
select c.email 
from contacts c
where
	 c.email is not null   
	 and to_char(sysdate, 'D') = 2  
	 and c.all = 'y'


Regards

Techno
Re: Conditional Selection [message #244045 is a reply to message #244041] Mon, 11 June 2007 07:54 Go to previous messageGo to next message
TonSchoen
Messages: 24
Registered: June 2007
Junior Member
The last line is

c.all = 'y

I think it should be

c.all = 'y'

You forgot to type the last quote.
Re: Conditional Selection [message #244258 is a reply to message #244045] Tue, 12 June 2007 03:17 Go to previous message
toastmax
Messages: 16
Registered: November 2006
Junior Member
The UNION solution seemed to work OK, many thanks
Previous Topic: Database closing issue
Next Topic: How can I stop a job at a particular time.
Goto Forum:
  


Current Time: Sun Dec 04 23:05:43 CST 2016

Total time taken to generate the page: 0.11666 seconds