This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
kurs:group_by_beispiele [2013/10/21 13:05] mh |
kurs:group_by_beispiele [2020/05/18 11:25] admin |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | <code> | ||
+ | select | ||
+ | department_name, | ||
+ | count(*) c | ||
+ | from employees e join departments d | ||
+ | on e.department_id = d.department_id | ||
+ | group by | ||
+ | department_name | ||
+ | having count(*) >= 5 | ||
+ | order by c desc | ||
+ | </code> | ||
+ | |||
+ | |||
+ | <code> | ||
+ | with ym as ( | ||
+ | select employee_id, | ||
+ | -- extract(year from hire_date) y, | ||
+ | extract(month from hire_date) m | ||
+ | from employees | ||
+ | ) | ||
+ | select m, count(employee_id) | ||
+ | from ym | ||
+ | group by m | ||
+ | order by m | ||
+ | </code> | ||
+ | |||
+ | |||
+ | |||
<code> | <code> | ||
with gehaltklassen as ( | with gehaltklassen as ( |