SQL HAVİNG DİTİNC GROUP BY FONKSİYONLARI

SELECT MAX(HIRE_DATE) AS İLKGİRİS, MIN(HIRE_DATE) AS SONGİRİS -- İŞE İLK GİRİŞ VE SON GİRİŞ TARİHİNİ GETİRME
FROM EMPLOYEES

SELECT COUNT (*)  FROM EMPLOYEES WHERE DEPARTMENT_ID=22 -- SATIRLARI SAYAR


SELECT COUNT (DISTINCT DEPARTMENT_ID) FROM EMPLOYEES -- KAC FARKLI KATEGORİYE KAYITLI ELEMN VAR 

SELECT AVG(COMMISSION_PCT) FROM EMPLOYEES  ---  ORTALAMA ALIR

SELECT DISTINCT DEPARTMENT_ID, AVG(SALARY) FROM EMPLOYEES GROUP BY DEPARTMENT_ID -- GURUBU TOPLAR ORTALAAM AALIR 


SELECT JOB_ID, MAX(SALARY) FROM EMPLOYEES
GROUP BY JOB_ID
HAVING MAX(SALARY)<4000 --- GRUPLARDA KISITLAMA YAPMAK İÇİN HAVİNG KULLANMAMIZ GEREKİR



SELECT MANAGER_ID, JOB_ID,  AVG(SALARY) FROM EMPLOYEES

GROUP BY MANAGER_ID,JOB_ID
ORDER BY MANAGER_ID

Bir cevap yazın

E-posta hesabınız yayımlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir