INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Jobs from Indeed

Select Case Statement in a crystal command

Select Case Statement in a crystal command

(OP)
I am trying to create a command in crystal with the following and I keep getting errors...somethin about an interval qualifier at the end of the statement.  Any ideas??

SELECT *
FROM  KCMS.FCT_WEK_LVL_COU
WHERE
CASE
   WHEN rpt_cd in ('58','59','60','62','63') Then 'LCM Themed'
   WHEN rpt_cd in ('21','22','23','25','26','27') Then 'Kroger Personal Finance'
   WHEN rpt_cd in ('44','45','46','48','51','53') Then 'Corporate Programs'
ELSE 'Other'
END;

Thanks!

RE: Select Case Statement in a crystal command

Hi,
Your CASE clause does not create a criteria for
the WHERE to use - What you want is something like this:

CODE

SELECT K.*,(
CASE
   WHEN rpt_cd in ('58','59','60','62','63') Then 'LCM Themed'
   WHEN rpt_cd in ('21','22','23','25','26','27') Then 'Kroger Personal Finance'
   WHEN rpt_cd in ('44','45','46','48','51','53') Then 'Corporate Programs'
ELSE 'Other'
END
) ReportCode
FROM  KCMS.FCT_WEK_LVL_COU K

You probably should use an explicit list of fields instead of * in this case so the rpt_cd is not repeated.



 

profile

To Paraphrase:"The Help you get is proportional to the Help you give.."

RE: Select Case Statement in a crystal command

You would need the CASE statement to provide a condition.  Putting the statement the way you have is akin to:

select * from table
where column

instead of

select * from table
where column  = 'X'

So you would need to compare the output of your CASE statement to something e.g. a column or input variable.

Retired (not by choice) Oracle contractor.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close