use hr ——TABLO OLUŞTURMA——- CREATE TABLE OGRENCI ( OGR_NO INT, ADI NVARCHAR(50), SOYADI NVARCHAR(100), BOLUMU INT NOT NULL, EMAIL NVARCHAR(50), KAYITTARIHI DATE NOT NULL ) ——–TABLOYA OGRENCI GIRISI YAPMA———— INSERT INTO OGRENCI VALUES (123,’HASAN’,’AYLAS’,1,NULL,GETDATE()) —— TABLO OLUSTURMA YAPMA————— CREATE TABLE DDDDD( BOLUM_ID INT NOT NULL IDENTITY UNIQUE, — BİRDEN FAZLA KISITLAMA YAPABİLME BULUMADI NVARCHAR ) […]

VERİTABANININDAKİ HERSEYİ SİLER TEHLİKELİ BİR KOMUTTUR. DENEMESİ BİLE SIKINTI VEREBİLİR YEDEK ALIP DENERSENİZ İYİ OLUR.  NOT ŞAKA AMACLI BİLE KULLANMAYINIZ. TRUNCATE TABLE HASAN — NE VAR NE YOK TABLODAKİLERİ GERİ DÖNMEKSİSİZİN SİLER

BİR TABLOYU BASKA BİR YENİ TABLOYA AKTARMAK İÇİN ASAĞIDAKİ  KODU KULLANABİLİRSİNİZ. SELECT * INTO HASAN FROM EMPLOYEES — HASAN ADINDA YENİ TABLO OLUŞTUR VE ONUN İÇİNDE EMPLOYESİ AKTAR SELECT EMPLOYEE_ID,LAST_NAME,D.DEPARTMENT_NAME INTO EMP3 —- YENİ EMP 3 ADINDA TABLO OLUŞTUR VE ONUN İÇİNDE VAR OLAN EMPLOYETEN VERİLERİ AKTAR FROM EMPLOYEES E, DEPARTMENTS D WHERE D.DEPARTMENT_ID=E.DEPARTMENT_ID

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