— MARKET KATEGORİNDEKİ MÜŞTERİLERİ LİSTELE SELECT FIRST_NAME, LAST_NAME, SALARY FROM EMPLOYEES WHERE DEPARTMENT_ID= (SELECT DEPARTMENT_ID FROM DEPARTMENTS WHERE DEPARTMENT_NAME=’Marketing’) — AYNI İŞLEMİ JOİNLE YAPMA SELECT * FROM EMPLOYEES E JOIN DEPARTMENTS D ON E.DEPARTMENT_ID=D.DEPARTMENT_ID AND D.DEPARTMENT_NAME=’Marketing’

SELECT * FROM EMPLOYEES CROSS JOIN DEPARTMENTS ————————-İÇ İÇE SORGULAR——————— SELECT *FROM EMPLOYEES WHERE SALARY >(SELECT SALARY FROM EMPLOYEES WHERE LAST_NAME LIKE ‘Abel’) — ABELDEN YKSEK MAASI OLAN PERSONELLER SELECT * FROM EMPLOYEES WHERE SALARY =(SELECT MIN(SALARY) FROM EMPLOYEES ) SELECT DEPARTMENT_ID, MIN(SALARY) FROM EMPLOYEES GROUP BY DEPARTMENT_ID HAVING MIN(SALARY) >(SELECT MIN(SALARY) FROM EMPLOYEES WHERE […]

————————————— SELECT * FROM REGIONS ————————————— SELECT COUNT(*) FROM COUNTRIES SELECT * FROM REGIONS,COUNTRIES — TABLOLARI BİRLEŞTİREBİLİRİZ SELECT * FROM REGIONS R ,COUNTRIES C WHERE R.REGION_ID=C.REGION_ID– ANLAMLI CIKTI ALABİLİRİZ SELECT * FROM DEPARTMENTS SELECT * FROM LOCATIONS SELECT D.DEPARTMENT_NAME, L.CITY FROM DEPARTMENTS D ,LOCATIONS L WHERE D.LOCATION_ID=L.LOCATION_ID SELECT E.FIRST_NAME, E.LAST_NAME, J.JOB_TITLE FROM JOBS J, EMPLOYEES […]

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 […]

    SELECT CASE SIGN (-125) WHEN 1 THEN ‘POZİTİF’ — KOSUL SAĞLANIRSA POZİTİF WHEN 0 THEN ‘NEGATİF’– KOSUL SAĞLANIRSA NEGATİF ELSE ‘BOS’ END — KOSUL SAĞLANMIYORSA BOS YAZDUR SELECT LAST_NAME,SALARY,JOB_ID, CASE JOB_ID — BİR ÖRNEK WHEN ‘AD_PRES’ THEN 1.5*SALARY– AD PRES YAZANLARA BİRBUCUK KAT ZAM YAP ELSE SALARY END FROM EMPLOYEES

use HR –CAST FONKSİYONU– SELECT LAST_NAME, DATEDIFF(YEAR, HIRE_DATE,GETDATE()) AS WEEKS — TARİH ARALIĞINDAKİLERİ GETİR FROM EMPLOYEES WHERE DEPARTMENT_ID=90 SELECT CONVERT (INT,(CONVERT(FLOAT, ‘6.7’,0))) — DÖNÜŞTÜRÜR SELECT LAST_NAME, UPPER(CONCAT(SUBSTRING (LAST_NAME,1,8),’_US’)) FROM EMPLOYEES WHERE DEPARTMENT_ID=60– AL BUYUT EKLE SELECT LAST_NAME,FIRST_NAME, ISNULL(CONVERT(NVARCHAR,COMMISSION_PCT),’BOS’) FROM EMPLOYEES — NULL OLANLARI BOS İLE DĞEİŞTİR KOMUTU

use HR select ROUND (3.44,5)– yuvarlama yapar select ABS (-1234)– mutlak değer alır select POWER (3,4)– ÜST değer alır select avg (salary) as ortalama from EMPLOYEES– tüm satırları toplayıp satır sayısına böler select max (salary) as ortalama from EMPLOYEES — en yuksek bir tanesini getirir select min (salary) as ortalama from EMPLOYEES — en düşük […]

SQL LOWER UPPER , LEN , CHARINDEX, REPLACE, TRIM FONSİYONLARI ORNELKERİ SELECT SUBSTRING (LAST_NAME,3,5) FROM EMPLOYEES — SUBSTRING 3, KARAKTER DEN BASLAYIP 5 KARAKTER GETİR WHERE LOWER (LAST_NAME) LIKE ‘__k%’ –LOWER FONKSİYONU TÜM KARAKTERİ KÜCÜLTÜR SELECT SUBSTRING (‘MERHABA DUNYA’,9,3) — LEN FONKDİYONU SELECT LEN (LAST_NAME) FROM EMPLOYEES — LEN KAC KARAKTER OLDUĞUNU SAYAR –CHARINDEX FPNSİYONU […]

SQL DE BİRLEŞTİRME YAPMAK İÇİN KOLONLR İÇİN CONCAT KULLANILABİLİR ASAĞIDA ÖRNEKTE GÖREBİLRİSİNİZ SELECT CONCAT (LAST_NAME,JOB_ID,’ MESLESĞİ’, JOB_ID) FROM EMPLOYEES — CONCAT BİRLEŞTİRME İŞLEMİ YAPAR WHERE LOWER (LAST_NAME) LIKE ‘__k%’ –LOWER FONKSİYONU TÜM KARAKTERİ KÜCÜLTÜR  

LOWER VE UPPER  KOMUT ÖRNEKLERİ SELECT FIRST_NAME, LOWER (LAST_NAME), JOB_ID FROM EMPLOYEES WHERE LOWER (LAST_NAME) LIKE ‘__k%’ –LOWER FONKSİYONU TÜM KARAKTERİ KÜCÜLTÜR SELECT FIRST_NAME, UPPER (LAST_NAME), JOB_ID FROM EMPLOYEES WHERE UPPER (LAST_NAME) LIKE ‘__k%’ –UPPER FONKSİYONU TÜM KARAKTERİ BÜYÜTÜR