This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | Next revision Both sides next revision | ||
kurs:einfache_selects [2013/04/29 12:46] mh |
kurs:einfache_selects [2014/05/12 12:29] mh |
||
---|---|---|---|
Line 46: | Line 46: | ||
-- commission_pct in (0.15, 0.2, 0.3, null) | -- commission_pct in (0.15, 0.2, 0.3, null) | ||
</code> | </code> | ||
+ | |||
+ | <code> | ||
+ | with emp_com as ( | ||
+ | select first_name, | ||
+ | last_name, | ||
+ | hire_date, | ||
+ | salary, | ||
+ | coalesce(commission_pct, 0) comm_pct | ||
+ | from employees | ||
+ | ) | ||
+ | select first_name, | ||
+ | last_name, | ||
+ | hire_date, | ||
+ | salary, | ||
+ | comm_pct, | ||
+ | salary * comm_pct "der bonus" | ||
+ | from emp_com | ||
+ | </code> | ||
+ | |||
+ | <code> | ||
+ | /* create view v_emp_com as | ||
+ | select first_name, | ||
+ | last_name, | ||
+ | hire_date, | ||
+ | salary+5 salary, | ||
+ | coalesce(commission_pct, 0) comm_pct | ||
+ | from employees | ||
+ | */ | ||
+ | |||
+ | select first_name, | ||
+ | last_name, | ||
+ | hire_date, | ||
+ | salary, | ||
+ | comm_pct, | ||
+ | salary * comm_pct "der bonus" | ||
+ | from v_emp_com | ||
+ | </code> | ||
+ |