User Tools

Site Tools


kurs:case

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

kurs:case [2014/09/10 21:22]
127.0.0.1 external edit
kurs:case [2015/10/19 10:58] (current)
mh
Line 7: Line 7:
  from employees order by hire_date desc;  from employees order by hire_date desc;
 </​code>​ </​code>​
 +
 +<​code>​
 +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'​) ​
 +</​code> ​    
  
 decode decode
kurs/case.txt ยท Last modified: 2015/10/19 10:58 by mh