Guest User

Untitled

a guest
Jun 20th, 2018
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. mysql> select count(*), avg(cast(datediff(hire_date, birth_date)/365 as decimal(20,15))) from employees join dept_emp using (emp_no) join departments using (dept_no) where dept_no='d001' group by dept_emp.dept_no;
  2. +----------+------------------------------------------------------------------+
  3. | count(*) | avg(cast(datediff(hire_date, birth_date)/365 as decimal(20,15))) |
  4. +----------+------------------------------------------------------------------+
  5. | 20211 | 31.5440424069036663203 |
  6. +----------+------------------------------------------------------------------+
  7. 1 row in set (0.07 sec)
  8.  
  9. mysql> select count(*), avg(cast(datediff(hire_date, birth_date)/365 as decimal(20,15))) from employees join dept_emp using (emp_no) join departments using (dept_no) group by dept_emp.dept_no;
  10. +----------+------------------------------------------------------------------+
  11. | count(*) | avg(cast(datediff(hire_date, birth_date)/365 as decimal(20,15))) |
  12. +----------+------------------------------------------------------------------+
  13. | 20211 | 31.5440424069036663203 |
  14. | 17346 | 31.5176717535990430070 |
  15. | 17786 | 31.5703832006986956033 |
  16. | 73485 | 31.5165073474792270531 |
  17. | 85707 | 31.4997869928167594246 |
  18. | 20117 | 31.5653590872056966745 |
  19. | 52245 | 31.5219184632247296392 |
  20. | 21126 | 31.5049994872476569156 |
  21. | 23580 | 31.5070884306113231552 |
  22. +----------+------------------------------------------------------------------+
  23. 9 rows in set (1.68 sec)
Add Comment
Please, Sign In to add comment