On the move:

I'm currently moving the following to their own blogs: Unix, HTML for Blogs, Perl & Java.
The links are on the left side.

Tuesday, July 14, 2015

Where Case


I wish I could think of a good reason to have a CASE statement in a WHERE statement -- but I can't so I'll just show something that works.

One day...
SELECT ename
     , job
     , deptno
  FROM scott.emp
WHERE job LIKE
              CASE
                 WHEN deptno = '20' THEN '%AL%'
                 WHEN deptno = '30' THEN '%MAN%'
              END
ORDER BY deptno, job
;

No comments:

Post a Comment