﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Northwind Veritabanı Sorguları &#8211; SQL Server Eğitimleri</title>
	<atom:link href="https://sqlserveregitimleri.com/etiket/northwind-veritabani-sorgulari/feed" rel="self" type="application/rss+xml" />
	<link>https://sqlserveregitimleri.com</link>
	<description>SQL Server ile ilgili her şey</description>
	<lastBuildDate>Wed, 13 Oct 2021 21:27:54 +0000</lastBuildDate>
	<language>tr</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.1</generator>
	<item>
		<title>SQL Server&#8217;da Northwind Veritabanı Sorgu Örnekleri</title>
		<link>https://sqlserveregitimleri.com/sql-serverda-northwind-veritabani-sorgu-ornekleri</link>
		
		<dc:creator><![CDATA[Yavuz Selim Kart]]></dc:creator>
		<pubDate>Wed, 13 Oct 2021 21:23:35 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Northwind Veritabanı Sorgu Örnekleri]]></category>
		<category><![CDATA[Northwind Veritabanı Sorguları]]></category>
		<category><![CDATA[SQL Sorgu Örnekleri]]></category>
		<guid isPermaLink="false">https://sqlserveregitimleri.com/?p=11181</guid>

					<description><![CDATA[Herkese merhaba, Bu yazıda SQL Server&#8217;da Northwind veri tabanı sorgu örneklerini sizlerle paylaşacağım. Kodları kendiniz deneyimleyin, anlamadığınız nokta olursa Youtube Kanalımdan videoları izleyebilirsiniz. Abone olursanız...]]></description>
										<content:encoded><![CDATA[<p>Herkese merhaba,</p>
<p>Bu yazıda SQL Server&#8217;da <strong>Northwind</strong> veri tabanı sorgu örneklerini sizlerle paylaşacağım.</p>
<p>Kodları kendiniz deneyimleyin, anlamadığınız nokta olursa <a href="https://www.youtube.com/c/SQLServerE%C4%9Fitimleri">Youtube Kanalımdan</a> videoları izleyebilirsiniz. Abone olursanız sevinirim.</p>
<p>SQL Server&#8217;da kendinizi ilerletmek istiyorsanız bol bol pratik yapmalısınız.</p>
<p>Bu noktada aşağıdaki soruları çözmeniz oldukça önemli.</p>
<p><strong>1 -) Çalışanların sayısını listeleyelim.</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT COUNT(*) [Calisan Sayisi]
FROM dbo.Employees;</code></pre>
<p><strong>2 -) Çalışanların ad ve soyadlarını listeleyelim.</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT FirstName,
       LastName,
       FirstName + ' ' + LastName AS [Ad Soyad]
FROM dbo.Employees;</code></pre>
<p><strong>3 -) Patronu listeleyelim, Çalışan kadınları listeleyelim.</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT FirstName,
       LastName
FROM dbo.Employees
WHERE TitleOfCourtesy = 'Dr.';

SELECT *
FROM dbo.Employees
WHERE TitleOfCourtesy IN ( 'Ms.', 'Mrs.' );

SELECT *
FROM dbo.Employees
WHERE TitleOfCourtesy = 'Ms.'
      OR TitleOfCourtesy = 'Mrs.';</code></pre>
<p><strong>4 -) Çalışan erkekleri listeleyelim.</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT *
FROM dbo.Employees
WHERE TitleOfCourtesy = 'Mr.';

SELECT FirstName,
       LastName
FROM dbo.Employees
WHERE TitleOfCourtesy = 'Mr.';</code></pre>
<p><strong>5 -) Çalışan erkek ve kadın sayılarını bulalım.</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT COUNT(*) AS CalisanErkek
FROM dbo.Employees
WHERE TitleOfCourtesy = 'Mr.';

SELECT COUNT(*) AS CalisanKadin
FROM dbo.Employees
WHERE TitleOfCourtesy IN ( 'Ms.', 'Mrs.' );</code></pre>
<p><strong>6 -) Çalışanlar kaç farklı şehirde çalışıyor listeleyelim.</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT DISTINCT
       City
FROM dbo.Employees;</code></pre>
<p><strong>7 -) Doğum tarihi 1960-05-29 dan büyük olanları listeleyelim.</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT *
FROM dbo.Employees
WHERE BirthDate &gt; '1960-05-29';</code></pre>
<p><strong>8 -) Adresinin içinde House geçen kişileri listeleyelim.</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT FirstName,
       LastName
FROM dbo.Employees
WHERE [Address] LIKE '%House%';</code></pre>
<p><strong>9 -) Extension kolonu 3 haneli olanları listeleyelim.</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT Extension
FROM dbo.Employees
WHERE LEN(Extension) = 3;

SELECT *
FROM dbo.Employees
WHERE LEN(Extension) = 4;</code></pre>
<p><strong>10 -) Çalışanların yaşlarını bulalım.</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT FirstName,
       LastName,
       DATEDIFF(YEAR, BirthDate, GETDATE()) AS YAS
FROM dbo.Employees;</code></pre>
<p><strong>11 -) Çalışanların işe kaç yaşında başladıklarını bulalım.</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT DATEDIFF(YEAR, BirthDate, HireDate) AS IseBaslangicTarihi
FROM dbo.Employees;</code></pre>
<p><strong>12 -) Region kolonu NULL olanları listeleyelim.</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT *
FROM dbo.Employees
WHERE Region IS NULL;</code></pre>
<p><strong>13 -) Çalışanların adlarını A&#8217;dan Z&#8217;ye ve Z&#8217;den A&#8217;ya listeleyelim.</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT FirstName
FROM dbo.Employees
ORDER BY FirstName ASC;

SELECT FirstName
FROM dbo.Employees
ORDER BY FirstName DESC;</code></pre>
<p><strong>14 -) Çalışanların adlarını A&#8217;dan Z&#8217;ye soyadlarını Z&#8217;den A&#8217;ya listeleyelim.</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT FirstName,
       LastName
FROM dbo.Employees
ORDER BY FirstName ASC,
         LastName DESC;</code></pre>
<p><strong>15 -) Şirket çalışanları ortalama yaşı nedir?</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT AVG(DATEDIFF(YEAR, BirthDate, GETDATE())) AS CalisanlarinToplamOrtalamaYasi
FROM dbo.Employees;</code></pre>
<p><strong>16 -) Müşteri adı A ile başlayan şirketler hangileridir?</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT *
FROM dbo.Customers
WHERE CompanyName LIKE 'A%';</code></pre>
<p><strong>17 -) Fax ve Region kısmı null olan müşteriler hangileridir?</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT *
FROM dbo.Customers
WHERE Fax IS NULL
      AND Region IS NULL;</code></pre>
<p><strong>18 -) CustomerID&#8217;si AA ile biten müşterileri listeleyelim.</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT *
FROM dbo.Customers
WHERE CustomerID LIKE '%AA';</code></pre>
<p><strong>19 -) Ürünlerin KDV dahil ve KDV hariç fiyatlarını ekrana yazdırın.</strong></p>
<pre class="line-numbers">SELECT ProductName,
UnitPrice AS KDVHaric,
(UnitPrice * 0.18 + UnitPrice) AS KDVDahil
FROM dbo.Products;</pre>
<p><strong>20 -) KDV&#8217;si 10 TL&#8217;den düşük olan ürünler hangileridir?</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT ProductName,
       (UnitPrice * 0.18) AS KDVUcreti
FROM dbo.Products
WHERE (UnitPrice * 0.18) &lt; 10;</code></pre>
<p><strong>21 -) En pahalı beş ürün nedir?</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT TOP 5
       ProductName,
       (UnitPrice * 0.18 + UnitPrice) AS KDVDahil
FROM dbo.Products
ORDER BY KDVDahil DESC;</code></pre>
<p><strong>22 -) En ucuz beş ürünün ortalama fiyatı nedir?</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT AVG(Tablomuz.UnitPrice) AS OrtalamaFiyat
FROM
(
    SELECT TOP 5
           UnitPrice
    FROM dbo.Products
    ORDER BY UnitPrice ASC
) AS Tablomuz;</code></pre>
<p><strong>23 -) Ürün adlarını büyüterek getir.</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT UPPER(ProductName)
FROM dbo.Products;</code></pre>
<p><strong>24 -) Stoğu olmayan ürünler kaç tanedir?</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT *
FROM dbo.Products
WHERE UnitsInStock = 0;</code></pre>
<p><strong>25 -) Stok Adedi 20 ile 50 arasındaki ürünlerini getirin</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT ProductName,
       UnitsInStock
FROM dbo.Products
WHERE UnitsInStock
BETWEEN 20 AND 50;</code></pre>
<p><strong>26 -) En pahalı ürünün fiyatını getirin.</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT MAX(UnitPrice)
FROM dbo.Products;</code></pre>
<p><strong>27 -) Kaç çeşit ürün var?</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT COUNT(ProductID)
FROM dbo.Products;</code></pre>
<p><strong>28 -) En pahalı ürünün adı nedir?</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT ProductName
FROM dbo.Products
WHERE UnitPrice =
(
    SELECT MAX(UnitPrice)FROM dbo.Products
);</code></pre>
<p><strong>29 -) Müşterilerin ülkelere göre sayılarını veren sorgu.</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT Country AS Ülke,
       COUNT(CustomerID) AS MusteriSayisi
FROM dbo.Customers
GROUP BY Country;</code></pre>
<p><strong>30 -) Her kategoriden kaç tane ürün var?</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT c.CategoryName,
       COUNT(p.ProductID) AS ToplamAdet
FROM dbo.Products p
    INNER JOIN dbo.Categories c
        ON c.CategoryID = p.CategoryID
GROUP BY CategoryName;</code></pre>
<p><strong>31 -) Çalışanlar ne kadarlık satış yapmışlar?</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT e.FirstName + ' ' + e.LastName AS CalisanAdSoyad,
       SUM(od.Quantity * od.UnitPrice) AS ToplamSatisMiktari
FROM dbo.Employees e
    INNER JOIN dbo.Orders o
        ON o.EmployeeID = e.EmployeeID
    INNER JOIN dbo.[Order Details] od
        ON od.OrderID = o.OrderID
GROUP BY e.FirstName + ' ' + e.LastName;</code></pre>
<p><strong>32 -) Hangi sipariş bana ne kadar kazandırmış?</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT OrderID,
       SUM(UnitPrice * Quantity * (1 - Discount)) AS Kazanc
FROM [Order Details]
GROUP BY OrderID;</code></pre>
<p><strong>33 -) 50&#8217;den fazla satışı olan çalışanlarımı nasıl bulurum?</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT e.FirstName + ' ' + e.LastName AS CalisanAdSoyad,
       COUNT(o.OrderID) AS SatisMiktari
FROM dbo.Orders o
    INNER JOIN dbo.Employees e
        ON e.EmployeeID = o.EmployeeID
GROUP BY e.FirstName + ' ' + e.LastName
HAVING COUNT(o.OrderID) &gt; 50;</code></pre>
<p><strong>34 -) 100 $ ya da TL&#8217;den büyük ürünleri görmek istiyorum.</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT ProductName
FROM dbo.Products
WHERE UnitPrice &gt; 100;</code></pre>
<p><strong>35 -) UnitsInStock (stok) değeri 15’un altında olan ürünlerin adı, fiyatı ve stok bilgileri.</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT ProductName,
       UnitPrice,
       UnitsInStock
FROM dbo.Products
WHERE UnitsInStock &lt; 15;</code></pre>
<p><strong>36 -) Brazil’de bulunan müşterilerin Şirket Adı, TemsilciAdi, Adres, Şehir, Ülke bilgileri.</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT CompanyName,
       ContactName,
       [Address],
       City,
       Country
FROM dbo.Customers
WHERE Country = 'Brazil';</code></pre>
<p><strong>37 -) Londra ve Paris&#8217;te yaşayan müşterilerimi listeleyin?</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT CompanyName,
       ContactName,
       City
FROM dbo.Customers
WHERE City IN ( 'London', 'Paris' );</code></pre>
<p><strong>38 -) Adı A harfi ile çalışan müşterilerimi listeleyin?</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT *
FROM dbo.Customers
WHERE ContactName LIKE 'A%';
SELECT *
FROM dbo.Customers
WHERE CompanyName LIKE 'A%';
SELECT CompanyName,
       ContactName,
       Phone
FROM dbo.Customers
WHERE CompanyName LIKE 'A%'
      AND ContactName LIKE 'A%';</code></pre>
<p><strong>39 -) 50$ ya da TL ile 100$ ya da TL arasında bulunan tüm ürünlerin adları ve fiyatları nelerdir?</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT ProductName,
       UnitPrice
FROM dbo.Products
WHERE UnitPrice
BETWEEN 50 AND 100;</code></pre>
<p><strong>40 -) Brezilya’da olmayan müşteriler.</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT CompanyName,
       ContactName,
       [Address],
       City,
       Country
FROM dbo.Customers
WHERE Country != 'Brazil';</code></pre>
<p><strong>41 -) Hem Mexico D.F’da ikamet eden hem de ContactTitle bilgisi &#8216;owner&#8217; olan müşterileri listeleyin.</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT CustomerID,
       ContactTitle,
       Address
FROM dbo.Customers
WHERE City = 'México D.F.'
      AND ContactTitle = 'Owner';</code></pre>
<p><strong>42 -) Satışı yapılmayan ürün listesi.</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT ProductName,
       UnitsInStock
FROM dbo.Products
WHERE Discontinued = 1;
SELECT ProductName,
       UnitsInStock
FROM dbo.Products
WHERE Discontinued = 1
      AND UnitsInStock &gt; 0;</code></pre>
<p><strong>43 -) Sipariş tarihleri 1 Haziran 1996 ile 30 Kasım 1993 tarihleri arasındaki siparişlerin OrderID ve ShipCountry bilgileri nedir?</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT OrderID,
       ShipCountry
FROM dbo.Orders
WHERE OrderDate
BETWEEN '1996-06-01' AND '1996-11-30';</code></pre>
<p><strong>44 -) Kaç farklı ülkeye ihracat yapılıyor?</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT COUNT(DISTINCT Country) AS UlkeSayisi
FROM dbo.Customers;</code></pre>
<p><strong>45 -) ALFKI CustomerID’sine sahip müşterimin sipariş sayısı nedir?</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT COUNT(*) AS SiparisSayisi
FROM dbo.Orders
WHERE CustomerID = 'ALFKI';</code></pre>
<p><strong>46 -) Müşterilerimin içinde en uzun isimli müşterinin (harf sayısı) nedir?</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT MAX(LEN(CompanyName)) AS MaksimumUzunluk
FROM dbo.Customers;</code></pre>
<p><strong>47 -) Hangi üründen toplam kaç adet satılmış?</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT ProductID,
       SUM(Quantity) AS AlinmişUrunAdedi
FROM dbo.[Order Details]
GROUP BY ProductID
ORDER BY AlinmişUrunAdedi DESC;</code></pre>
<p><strong>48 -) 1000 Adetten fazla satılan ürünler nelerdir?</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT ProductID,
       SUM(Quantity) AS AlinmişUrunAdedi
FROM dbo.[Order Details]
GROUP BY ProductID
HAVING SUM(Quantity) &gt; 1000;</code></pre>
<p><strong>49 -) Ortalamanın altında bir fiyata sahip ürünlerin adı ve fiyatı nedir?</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT AVG(UnitPrice)
FROM dbo.Products;

SELECT ProductName,
       UnitPrice
FROM dbo.Products
WHERE UnitPrice &lt;
(
    SELECT AVG(UnitPrice)FROM dbo.Products
);</code></pre>
<p><strong>50 -) Hangi müşteriler hiç sipariş vermemiş?</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT DISTINCT
       CustomerID
FROM dbo.Orders;

SELECT *
FROM dbo.Customers
WHERE CustomerID NOT IN
      (
          SELECT DISTINCT CustomerID FROM dbo.Orders
      );</code></pre>
<p><strong>51 -) Hangi ürün hangi kategoridedir?</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT ProductName,
       CategoryName
FROM dbo.Products
    INNER JOIN dbo.Categories
        ON Categories.CategoryID = Products.CategoryID;</code></pre>
<p><strong>52 -) Bütün nakliyecilerin listesi?</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT CompanyName
FROM dbo.Shippers;</code></pre>
<p><strong>53 -) Hangi çalışanım hangi bölgeden sorumludur?</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT e.LastName + ' ' + e.LastName AS AdSoyad,
       t.TerritoryDescription
FROM dbo.Employees e
    INNER JOIN dbo.EmployeeTerritories et
        ON et.EmployeeID = e.EmployeeID
    INNER JOIN dbo.Territories t
        ON t.TerritoryID = et.TerritoryID;

SELECT e.LastName + ' ' + e.LastName AS AdSoyad,
t.TerritoryDescription
FROM dbo.Employees e
INNER JOIN dbo.EmployeeTerritories et
ON et.EmployeeID = e.EmployeeID
INNER JOIN dbo.Territories t
ON t.TerritoryID = et.TerritoryID
WHERE e.LastName + ' ' + e.LastName = 'Buchanan Buchanan';</code></pre>
<p><strong>54 -) Hangi tedarikçi hangi ürünü sağlıyor? </strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT ProductName,
       CompanyName
FROM dbo.Products
    INNER JOIN dbo.Suppliers
        ON Suppliers.SupplierID = Products.SupplierID;</code></pre>
<p><strong>55 -) Beverages kategorisine ait ürünlerin listesi.</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT *
FROM dbo.Products
WHERE CategoryID =
(
    SELECT CategoryID FROM dbo.Categories WHERE CategoryName = 'Beverages'
);</code></pre>
<p><strong>56 -) Micheal&#8217;ın yada Laura&#8217;nın hemşerisi olan çalışanları listeleyelim?</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT *
FROM dbo.Employees
WHERE City IN
      (
          SELECT City FROM dbo.Employees WHERE FirstName IN ( 'Michael', 'Laura' )
      );</code></pre>
<p><strong>57 -) Ürünlerimin karşısına kategori getirme.</strong></p>
<pre class="line-numbers"><code class="language-sql">SELECT p.ProductName,
       (
           SELECT c.CategoryName
           FROM dbo.Categories c
           WHERE c.CategoryID = p.CategoryID
       ) AS CategoryName
FROM dbo.Products p;

SELECT ProductName,
       CategoryName
FROM dbo.Products
    INNER JOIN dbo.Categories
        ON Categories.CategoryID = Products.CategoryID;</code></pre>
<p>Yukarıda yazdığım sorulara zamanla yeni sorular ekleyeceğim.</p>
<p>Herkese çalışma hayatında ve yaşamında başarılar kolaylıklar.</p>
<div class='epvc-post-count'><span class='epvc-eye'></span>  <span class="epvc-count"> 2.234</span><span class='epvc-label'> Kez Okundu</span></div>]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
