Advertisement
patryk

Untitled

Mar 18th, 2015
559
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 2.05 KB | None | 0 0
  1. -- ZAD 1
  2. SELECT MIN(PLACA_POD) AS MINIMUM, MAX(PLACA_POD) AS MAKSIMUM, MAX(PLACA_POD) - MIN(PLACA_POD) AS RÓŻNICA FROM PRACOWNICY
  3.  
  4. -- ZAD 2
  5. SELECT ETAT, AVG(PLACA_POD) FROM PRACOWNICY GROUP BY ETAT ORDER BY AVG(PLACA_POD) DESC
  6.  
  7. -- ZAD 3
  8. SELECT COUNT(*) AS PROFESOROWIE FROM PRACOWNICY GROUP BY ETAT HAVING ETAT = 'PROFESOR'
  9.  
  10. -- ZAD 4
  11. SELECT ID_ZESP, SUM(PLACA_POD) + SUM(PLACA_DOD) AS SUMARYCZNA_PLACA FROM PRACOWNICY GROUP BY ID_ZESP
  12.  
  13. -- ZAD 5
  14. SELECT MAX(SUM(PLACA_POD) + SUM(PLACA_DOD)) AS MAX_SUM_PRACA FROM PRACOWNICY GROUP BY ID_ZESP
  15.  
  16. -- ZAD 6
  17. SELECT ID_SZEFA, MIN(PLACA_POD) AS MINIMALNA FROM PRACOWNICY GROUP BY ID_SZEFA ORDER BY MIN(PLACA_POD) DESC
  18.  
  19. -- ZAD 7
  20. SELECT ID_ZESP, COUNT(ID_ZESP) AS ILE_PRACUJE FROM PRACOWNICY GROUP BY ID_ZESP ORDER BY COUNT(ID_ZESP) DESC
  21.  
  22. -- ZAD 8
  23. SELECT ID_ZESP, COUNT(ID_ZESP) AS ILE_PRACUJE FROM PRACOWNICY GROUP BY ID_ZESP HAVING COUNT(ID_ZESP) > 3 ORDER BY COUNT(ID_ZESP) DESC
  24.  
  25. -- ZAD 9
  26. SELECT ID_PRAC FROM PRACOWNICY GROUP BY ID_PRAC HAVING COUNT(ID_PRAC) > 1
  27.  
  28. -- ZAD 10
  29. SELECT ETAT, AVG(PLACA_POD), COUNT(*) FROM PRACOWNICY WHERE ZATRUDNIONY <= DATE '1990-01-01' GROUP BY ETAT
  30.  
  31. -- ZAD 11
  32. SELECT ID_ZESP, ETAT, ROUND(AVG(PLACA_POD + NVL(PLACA_DOD, 0))) AS ŚREDNIA, ROUND(MAX(PLACA_POD + NVL(PLACA_DOD, 0))) AS MAKSYMALNA FROM PRACOWNICY WHERE ETAT = 'PROFESOR' OR ETAT = 'ASYSTENT' GROUP BY ID_ZESP, ETAT ORDER BY ID_ZESP
  33.  
  34. -- ZAD 12
  35. SELECT EXTRACT(YEAR FROM ZATRUDNIONY) AS ROK, COUNT(*) AS ILU_PRACOWNIKOW FROM PRACOWNICY GROUP BY EXTRACT(YEAR FROM ZATRUDNIONY) ORDER BY EXTRACT(YEAR FROM ZATRUDNIONY)
  36.  
  37. -- ZAD 13
  38. SELECT LENGTH(NAZWISKO) AS ILE_LITER, COUNT(*) AS W_ILU_NAZWISKACH FROM PRACOWNICY GROUP BY LENGTH(NAZWISKO) ORDER BY LENGTH(NAZWISKO)
  39.  
  40. -- ZAD 14
  41. --SELECT COUNT(*) AS ILE_NAZWISK_Z_A, COUNT(*) - 2 AS ILE_NAZWISK_Z_E FROM PRACOWNICY WHERE INSTR(NAZWISKO, 'A') != 0 OR INSTR(NAZWISKO, 'a') != 0
  42. --BTW TO NIE DZIALA, TAKI ZARCIK KOSMONALCIK
  43.  
  44. SELECT COUNT(TRANSLATE(SIGN(INSTR(NAZWISKO, 'A')), '10', '1')) AS ILE_Z_A, COUNT(TRANSLATE(SIGN(INSTR(NAZWISKO, 'E')), '10', '1')) AS ILE_Z_E FROM PRACOWNICY
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement