Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


SQL CASE Expression, ELSE  run "ALL"

Posted on 2007-10-02
Medium Priority
Last Modified: 2010-08-05
I am using the following  case expression in an Oracble/PeopleSoft database:
WHEN 'bbbbb' THEN B. DEPTID in ('50000','11100','22200','333300)
WHEN 'aaaaa' THEN B. DEPTID in ('41111', 77700, "99900)
else 0
How would I change the else to ELSE run all departments.  (:1 is a prompt that indicates a userID).  When the UserId is not either 'aaaaa' or 'bbbbb', I need the query to run all departments  Note:  without the CASE expression, the query runs all departments.  
Question by:syhctl
LVL 143

Accepted Solution

Guy Hengel [angelIII / a3] earned 2000 total points
ID: 19999125
WHEN 'bbbbb' THEN B. DEPTID in ('50000','11100','22200','333300)
WHEN 'aaaaa' THEN B. DEPTID in ('41111', 77700, "99900)
else 1=1

Author Comment

ID: 19999725
Thanks - that was probably a stupid question, but sometimes the brain just ain't functioning.

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Suggested Courses

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question