Advertisement
Alhiris

Untitled

Apr 14th, 2020
641
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.78 KB | None | 0 0
  1. --6
  2. --27 rows
  3. --count(*) broken when you left join, returns 1 no matter what...
  4. SELECT
  5.     'Departamentul '
  6.     || D.DEPARTMENT_NAME
  7.     || ' este condus de '
  8.     || NVL(TO_CHAR(D.MANAGER_ID), 'nimeni')
  9.     || ' si '
  10.     || DECODE(COUNT(E.EMPLOYEE_ID), 0, 'nu are salariati', 'are numarul de angajati '
  11.                                                            || TO_CHAR(COUNT(E.EMPLOYEE_ID)))
  12. --    || DECODE(COUNT(E.EMPLOYEE_ID), 0, ', de ce count(*)='
  13. --                                       || COUNT(*)
  14. --                                       || '?', '') STATEMENT
  15. FROM
  16.     DEPARTMENTS   D,
  17.     EMPLOYEES     E
  18. WHERE
  19.     E.DEPARTMENT_ID (+) = D.DEPARTMENT_ID
  20. GROUP BY
  21.     D.DEPARTMENT_ID,
  22.     D.DEPARTMENT_NAME,
  23.     D.MANAGER_ID;
  24. --ORDER BY
  25. --    COUNT(E.EMPLOYEE_ID);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement