İstanbul

İstanbul

7 Mart 2015 Cumartesi

SQL SUBQUERY Kullanımı

* Son çalışanın bilgilerini getiren sorguyu yazınız (With SubQuery)
SelectFrom Employees where EmployeeID = (Select MAX(EmployeeID) From Employees)

Select *,(Select kat.CategoryName From Categories kat where kat.CategoryID = urun.CategoryID) as KategoriAdi From Products urun

* Region yani bölge bilgisi boş olan çalışanlarınızın yaşlarının ortalamasını getiren sorguyu yazınız.
Select  AVG(DATEDIFF(YY,BirthDate,GETDATE())) From Employees Where Region Is Null

* Her bir ürün için verilmiş en yüksek sipariş miktarını listeleyiniz.
Select DISTINCT ProductID,Quantity From [Order Details] as OD1 
where Quantity=( Select MAX(Quantity) From [Order Detailsas OD2       where OD1 .ProductID=OD2.ProductIDOrder By ProductID


Hiç yorum yok:

Yorum Gönder