-
Notifications
You must be signed in to change notification settings - Fork 0
/
SQLQuery.sql
33 lines (21 loc) · 1.06 KB
/
SQLQuery.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
--Select
--ANSII and case insensitive
Select ContactName Adi,CompanyName SirketAdi,City Sehir from Customers
Select * from Customers where City = 'London'
select * from Products where categoryId=1 or CategoryID=3
select * from Products where categoryId=1 and UnitPrice>=10
select * from Products where categoryId=1 order by UnitPrice desc --default ascending
select count(*) Adet from Products where CategoryID=2
select categoryId,count(*) from Products where unitPrice>20 group by CategoryID having count(*)<10
select Products.ProductID, Products.ProductName, Products.UnitPrice, Categories.CategoryName
from products inner join Categories
on Products.CategoryID = Categories.CategoryID--if gibi
where Products.UnitPrice>10
--DTO: Data Transformation Object
Select * from Products p inner join [Order Details] od--Products'ta olup Order Details'te olmayanları da getir
on p.ProductID = od.ProductID
inner join Orders o
on o.OrderID = od.OrderID
Select * from Customers c left join Orders o
on c.CustomerID = o.CustomerID
where o.CustomerID is null--"sana özel" muhabbeti