+SELECT A.staff_id, A.first_name, A.emailfrom sale.staff As Awhere A.first_name = 'Davis';select * from sale.order_itemorder by order_item.list_price-- as it appears, default value is ASC for group byselect *from sale.customerorder by customer.first_name ASC, customer.last_name ASC;select *from sale.customerwhere sale.customer.state = 'MA' -- State konumunda MA olanlari aliyoruz .order by customer.first_name ASC--WHEREselect item.product_id, item.list_price -- sadece iki column u cagirdik from sale.order_item AS itemwhere item.list_price >= 200 -- item.list_price lari 200 den buyuk olanlari getirsinorder by item.list_price;-- BETWEENselect item.product_id, item.list_pricefrom sale.order_item AS itemwhere item.list_price between 200 and 230 -- list price lari 200 ile 230 arasi olmali . 230 >= x >= 200 order by item.list_price;select item.product_id, item.list_pricefrom sale.order_item AS itemwhere item.list_price >= 200 and item.list_price <=230 -- yukardakiyle ayni sonucu verir . order by item.list_priceselect item.product_id, item.list_pricefrom sale.order_item AS itemwhere item.list_price NOT BETWEEN 200 and 230order by item.list_price;-- INselect staff.first_name, staff.last_namefrom sale.staff AS staffwhere staff.first_name = 'Barbara'ORstaff.first_name = 'Taylor'ORstaff.first_name = 'Linda'order by staff.first_name;select staff.first_name, staff.last_namefrom sale.staff AS staffwhere staff.first_name in ('Barbara', 'Taylor', 'Linda')order by staff.first_name;select staff.first_name, staff.last_namefrom sale.staff AS staffwhere staff.first_name not in ('Barbara', 'Taylor', 'Linda')order by staff.first_name;select staff.first_name, staff.last_namefrom sale.staff AS staffwhere staff.first_name not in ('Barbara', 'Taylor', 'Linda') AND staff.first_name like 'b%'order by staff.first_name;-- LIKESELECT customer.first_name, customer.last_nameFROM sale.customer AS customerWHERE customer.first_name like 't%'ORDER BY customer.first_name;-- Finds any values that start with "t"SELECT customer.first_name, customer.last_nameFROM sale.customer AS customerWHERE customer.first_name like '%z'ORDER BY customer.first_name;-- Finds any values that end with "z"SELECT customer.first_name, customer.last_nameFROM sale.customer AS customerWHERE customer.first_name like '%ald%'ORDER BY customer.first_name;-- Finds any values that have "ald" in any positionSELECT customer.first_name, customer.last_nameFROM sale.customer AS customerWHERE customer.first_name like '_b%'-- Finds any values that have "b" in second positionSELECT customer.first_name, customer.last_nameFROM sale.customer AS customerWHERE customer.first_name like 't%y'ORDER BY customer.first_name;-- Finds any values that start with 't' and end with 'y'-- in LMS we saw a pattern like 't_y' but we can't get any output !!SELECT customer.first_name, customer.last_nameFROM sale.customer AS customerWHERE customer.first_name like 't_y'ORDER BY customer.first_name;-- burada _ tek karakter anlamina geliyor-- AND -- iki cond icin AND kullaniyoruzselect item.product_id, item.list_pricefrom sale.order_item AS itemwhere item.list_price >= 200 and item.list_price <=230 order by item.list_priceselect *from sale.customer as customerwhere customer.street like '%Dorigo%' and customer.city = 'Birmingham';SELECT stock.product_id , stock.quantity, stock.store_idFROM product.stock AS stockwhere stock.quantity = 0 and stock.store_id = '1'order by stock.quantity asc, stock.product_id;-- quantity si 0 ve store_id si 1 olanlari getir . SELECT stock.product_id , stock.quantity, stock.store_idFROM product.stock AS stockwhere stock.quantity = 0 or stock.quantity = 30order by stock.quantity asc;-- NOTSELECT stock.product_id , stock.quantity, stock.store_idFROM product.stock AS stockWHERE NOT stock.quantity = 0ORDER BY stock.quantity;--BETWEEN with Data ExampleSELECT *FROM sale.orders as ordersWHERE orders.shipped_date between orders.order_date and orders.required_dateORDER BY orders.order_date--order_date ile required_date arasindaki datayi getiriyor SELECT *FROM sale.orders as ordersWHERE orders.shipped_date between '2020-03-20' and '2020-03-22'ORDER BY orders.shipped_date
0 commit comments