-- productID 12 den küçükleri getiriniz.
select p.ProductID,p.ProductName from Products p where p.ProductID <12
-- productID 2 veya 4 , productName i içinde 'ang' ifadesi geçeni getiriniz.
select p.ProductID,p.ProductName from Products p where (p.ProductID=2 or p.ProductID=4) or p.ProductName like '%ang%'
-- productıd>20 ve productname 'g' ile başlayan aynı zamanda unitprice 50 den küçük olanların listesi getiriniz
select p.ProductID,p.ProductName,p.UnitPrice from Products p where p.ProductID>20 and p.ProductName like 'g%' and p.UnitPrice<50
--productname i Chai, Konbu, Chang olan ürünleri listeleyin and kullanmadan getiriniz.
select * from Products where ProductName IN ('Chai','Chang','Konbu')
-- Products tablosunda UnitsInStock (stok miktarı) 0 olan listeleyiniz.
select * from Products where UnitsInStock=0
-- Orders tablosunda sipariş tarihi 1996-07-04 ile 1997-07-01 tarihleri arasndakileri listeleyiniz
select * from Orders where OrderDate between '1996-07-04' and '1997-07-01'
-- product tablosunda sublierId 3 categoriID 4 olan diccountinued false olanları listele
select * from Products p where p.SupplierID=3 and p.CategoryID=2 and p.Discontinued='false'
-- Order tablosundaki customerId si alfki olanları getirin
select * from Orders o where o.CustomerID='alfki'
-- CustemerID si T harfi geçen EmployedID si 3 den farklı ve ShipVia sı 1 olan , orderdate i
1996.01.01 den büyük olanları listeleyiniz.
select * from Orders o where o.CustomerID like '%t%' and o.EmployeeID !=3 and o.ShipVia=1 and o.OrderDate >'1996-01-01'
--sipariş tablosunda ulaşılması gereken tarihin geç gitmesini sıralayın
select * from Orders o where o.RequiredDate<o.ShippedDate
--supplier tablosundaki region Québec olan ve ContactName 2. harfi h olanları
select * from Suppliers s where s.Region='Québec' and s.ContactName like '_h%'
--customer tablosundaki Country alanı UK olan kayıtların CompanyName,
ContactName,City,Conuntr alalnlarını listeletyiniz.
select c.CompanyName,c.ContactName,c.City,c.Country from Customers c where c.Country='UK'
--sipatisdetay tablosunda siparisid 10248 ile 10260 arasında ve fiyatları 16000 dan klucuk olan adet da 5 den fazla olanları listeleyiniz
select * from [Order Details] od where od.OrderID between 10248 and 10260 and od.UnitPrice<16000 and od.Quantity>5
-- orders tablosundan ShipRegion olmayan ShipCity si London olanların listeleyiniz.
select * from Orders where ShipRegion is NULL and ShipCity='LONDON'
--siparişi fiyatı en yüksek olanı getiriniz ürünler tablosundan
select MAX(od.UnitPrice*od.Quantity) from [Order Details] od
--ProductID si 20 den büyük olan ürünün almış olduğu siparişlerin ortalama fiyatını getiriniz.
select AVG(od.UnitPrice*od.Quantity) from [Order Details] od where od.ProductID>20
--ProductID si 20 den büyük olan ürünün almış olduğu siparişlerin fiyatını getiriniz.
select od.OrderID,od.ProductID, od.UnitPrice*od.Quantity as Fiyat from [Order Details] od where od.ProductID>20
Hiç yorum yok:
Yorum Gönder