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

Order By Case


This is a simple example of using CASE to get a specific order in your output.
SELECT ename
     , job
  FROM scott.emp
ORDER BY CASE job
               WHEN 'PRESIDENT' THEN 1
               WHEN 'MANAGER'   THEN 2
               WHEN 'ANALYST'   THEN 3
               WHEN 'SALESMAN'  THEN 4
                                ELSE 5
          END
;

No comments:

Post a Comment