If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Query help

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-11-11, 01:33
ruchis ruchis is offline
Registered User
 
Join Date: Jan 2011
Posts: 1
Query help

select distinct a.comp_code,a.process_code,a.nexus_year,a.nexus_se q_no ,
a.is_audit_mail_gen , (select param_val from nexus_process_config
where param_name like 'STEP_ID') step_id
from NEXUS_TR_DATA a, nexus_process_approval_mast b where
a.is_audit_mail_gen is null OR a.is_audit_mail_gen = ' '
and b.step_id IN (step_id)
and a.process_code = b.process_code
and a.comp_code = '5655'
and a.process_code = 'ITR'
DECODE (a.comp_code ,'5655','AND (sysdate between TO_DATE('01-JAN-11') AND TO_DATE('30-JAN-11'))',
'5663', 'AND (sysdate between TO_DATE('01-FEB-11') AND TO_DATE('15-JAN-11'))')



i am facing diff in the decode part. can sum1 tel wat m i doin wrong?
Reply With Quote
  #2 (permalink)  
Old 01-11-11, 04:29
it-iss.com it-iss.com is offline
Registered User
 
Join Date: Sep 2009
Location: San Sebastian, Spain
Posts: 623
Decode is not available in MySQL. Try using IF or CASE but in this case you need to write this using an OR: Also TO_DATE is not a valid function in MySQL.

Code:
select distinct a.comp_code,a.process_code,a.nexus_year,a.nexus_se q_no ,
a.is_audit_mail_gen , (select param_val from nexus_process_config
where param_name like 'STEP_ID') step_id
from NEXUS_TR_DATA a, nexus_process_approval_mast b where
a.is_audit_mail_gen is null OR a.is_audit_mail_gen = ' '
and b.step_id IN (step_id)
and a.process_code = b.process_code
and a.comp_code = '5655'
and a.process_code = 'ITR'
and ((a.comp_code = '5655' AND system between str_to_date('01-JAN-11', '%d-%m-%y') AND str_to_date('30-JAN-11','%d-%m-%y'))
OR (a.comp_code = '5663' AND sysdate between str_to_date('01-FEB-11', '%d-%m-%y') AND str_to_date('15-JAN-11', '%d-%m-%y')))
__________________
Ronan Cashell
Senior Oracle/MySQL DBA
http://www.it-iss.com

Last edited by it-iss.com; 01-11-11 at 04:36.
Reply With Quote
  #3 (permalink)  
Old 01-11-11, 05:01
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,535
Quote:
Originally Posted by ruchis View Post
can sum1 tel wat m i doin wrong?
you're typing with your thumbs again

this type of "language" has no place in query writing -- you're likely to make errors in your SQL syntax that way
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On