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') 
select first_name,
    last_name,
    salary,
    decode(gehalts_kategorie,
    0, 'wenig',
    1, 'mittel',
    2, 'viel',
    'FEHLER!!!') gehalts_kategorie_name
from (
select first_name,
       last_name,
       salary,       
(case when salary < 5000 then 0
      when salary < 10000 then 1
      else 2 
end) gehalts_kategorie
from hr.employees
) 
order by gehalts_kategorie, salary, last_name, first_name;

decode

kurs/case.txt · Last modified: 2020/05/11 09:26 by admin