User Tools

Site Tools


kurs:case
select last_name, to_char(hire_date, 'yyyy') as hy,
 (case when to_char(hire_date, 'yyyy')>1995 then 'jung'
       when to_char(hire_date, 'yyyy')>1992 then 'mittel'
       else 'alt'
  end) altersgruppe
 from employees order by hire_date desc;
select first_name,
       last_name,
       hire_date,
       age_class from
(select first_name,
       last_name,
       hire_date,
       case when hd < 2003 then 'old'
            when hd < 2005 then 'average'
            when hd < 2007 then 'young'
            else 'even younger' end age_class
  from 
  (select first_name, 
       last_name,
       hire_date,
       extract(year from hire_date) hd from employees))
 order by decode(age_class,
      'old', 0,
      'average', 1,
      'young', 2,
      'even younger', 3,
      'error') 

decode

kurs/case.txt · Last modified: 2015/10/19 10:58 by mh