ga('create', 'UA-36370145-1', 'auto'); ga('send', 'pageview');

case örnek

select * from employees

–bayan adı soyadı

select
case TitleOFCourtesy
when ‘MS.’ then ‘Bayan’
when ‘Mrs.’ then ‘Bayan’
when ‘Mr.’ then ‘Bay’
when ‘Dr.’ then ‘Doktor’
end as ‘Unvan’,
FirstName + ‘ ‘ + LastName as ‘Full Name’
from employees

–bay ve bayanın dışında ne gelirse boşluk atsın
select
case TitleOFCourtesy
when ‘MS.’ then ‘Bayan’
when ‘Mrs.’ then ‘Bayan’
when ‘Mr.’ then ‘Bay’
else ‘ ‘
end as ‘Unvan’,
FirstName + ‘ ‘ + LastName as ‘Full Name’
from employees

—homephone alanından counrty alanını yakalıcaz ve unvan fullname
select
case TitleOfCourtesy
when ‘MS.’ then ‘Bayan’
when ‘Mrs.’ then ‘Bayan’
when ‘Mr.’ then ‘Bay’
end as ‘Unvan’,
FirstName + ‘ ‘ + LastName as ‘Full Name’,HomePhone,
case when substring(homephone,3,2) = ‘206’ then ‘USA’
when substring(homephone,2,2) = ’71’ then ‘UK’
end as ‘Country’
from employees

—eğer kısıt koyacaksak case i boş bırakıp whene yazarız herşeyi
—ama kısıtsız bir cümleyse normal halinde yazarız

select *from orders

—bir müşterinin hangi zamanlarda sipariş verdiği tekrarsız olarak

select distinct (month(orderdate))
from orders
order by 1

–ayları isimlerine göre yazan sql cümlesi

select distinct (datename(month,orderdate))
from orders
order by 1

–bu ayların ismini türkçe olarak getiren sql cümlesi

select
case (month(orderdate))
when 1 then ‘Ocak’
when 2 then ‘Şubat’
when 3 then ‘Mart’
when 4 then ‘Nisan’
when 5 then ‘Mayıs’
when 6 then ‘Haziran’
when 7 then ‘Temmuz’
when 8 then ‘Ağustos’
when 9 then ‘Eylül’
when 10 then ‘Ekim’
when 11 then ‘Kasım’
when 12 then ‘Aralık’
end ‘Turkish Month Name’
from orders

—orderdate teki günlerin getir

select datepart(day,orderdate) as ‘DAY’
from orders

—orderdate teki günlerin haftanın kaçıncı günü olduunu getir

select datepart(weekday,orderdate) as ‘Wekk Day’
from orders

—orderdate deki günlerin ismini getir
select datename(weekday,orderdate) as ‘Week Day Name’
from orders

—hepsini birde gösterebiliriz
select datepart(day,orderdate) as ‘DAY’,
datepart(weekday,orderdate) as ‘Wekk Day’,
datename(weekday,orderdate) as ‘Week Day Name’
from orders

—günlerin isimlerini türkçe olarak göster
select datepart(day,orderdate) as ‘DAY’,
datepart(weekday,orderdate) as ‘Wekk Day’,
datename(weekday,orderdate) as ‘Week Day Name’
,case datepart(weekday,orderdate)
when 1 then ‘Pazartesi’
when 2 then ‘Salı’
when 3 then ‘Çarşamba’
when 4 then ‘Perşembe’
when 5 then ‘Cuma’
when 6 then ‘Cumartesi’
when 7 then ‘Pazar’
end as ‘Week Day Name Tr’
from orders

—yılın kaçıncı haftasını öğrenmek istersek
select datepart(day,orderdate) as ‘DAY’,
datepart(weekday,orderdate) as ‘Wekk Day’,
datename(weekday,orderdate) as ‘Week Day Name’
,datepart(week,orderdate) as ‘Week of Year’
,datepart(day,orderdate) a ‘Day of Year’
,case datepart(weekday,orderdate)
when 1 then ‘Pazartesi’
when 2 then ‘Salı’
when 3 then ‘Çarşamba’
when 4 then ‘Perşembe’
when 5 then ‘Cuma’
when 6 then ‘Cumartesi’
when 7 then ‘Pazar’
end as ‘Week Day Name Tr’
from orders

Ayrıca Buna Bakabilirsiniz

SQL Server: Login failed for User ‘NT AUTHORITY\ANONYMOUS LOGON

SQL Server: Login failed for User ‘NT AUTHORITY\ANONYMOUS LOGON’ Merhaba bu hata www.sqlogren.com sitesindeki en …

Bir yorum

  1. Geribildirim: Sql Dersleri | sql ders

Bir Cevap Yazın

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