본문 바로가기

데이터/초보자를 위한 SQL 200제

초보자를 위한 SQL 200제 -한 달에 책 한 권 끝내기- Day3

007~015

007where절 배우기 -1 (숫자 데이터 검색)

 

SELECT order_idx,status,paid_date,ebut_sku_code,order_qty,order_shipping_price
 FROM thegifting_personal_matche.erp_order_hst 
 where order_shipping_price > 5000;

SELECT order_idx,status,paid_date,ebut_sku_code,order_qty,order_shipping_price
 FROM thegifting_personal_matche.erp_order_hst 
 where order_shipping_price > 5000;

008where절 배우기 -2 (문자와 날짜 검색)

SELECT order_idx as '주문번호' ,status as '주문상태' ,paid_date as '결제일' ,ebut_sku_code as 'sku no'
,order_qty as '주문수량' ,order_shipping_price as '결제 금액'
FROM thegifting_personal_matche.erp_order_hst 
 where order_shipping_price > 3000
 and ebut_sku_code = "ITW-101-1590";

009 산술연산자 배우기 (*,/,+,-)

SELECT ebut_sku_code as 'sku no'
,order_qty * order_shipping_price as '결제 총 금액'
FROM thegifting_personal_matche.erp_order_hst 
 where order_shipping_price > 3000;

010 비교 연산자 배우기 -1 (>,<,>=,<=,=,!=,<>,^=)

SELECT ebut_sku_code as 'sku no'
,order_qty * order_shipping_price as '결제 총 금액'
FROM thegifting_personal_matche.erp_order_hst 
 where order_shipping_price != 3000 order by order_qty * order_shipping_price desc ;

011 비교 연산자 배우기 -2 (between and)

SELECT ebut_sku_code as 'sku no'
,order_qty * order_shipping_price as '결제 총 금액'
FROM thegifting_personal_matche.erp_order_hst 
 where order_qty * order_shipping_price  between 30000 and 36000 order by order_qty * order_shipping_price desc ;

012 비교 연산자 배우기 -3 (LIKE)

SELECT ebut_sku_code as "sku no", title as "상품명", products_title as "스타일" 
FROM thegifting_personal_matche.erp_product_sku_hst
WHERE products_title LIKE '%유리엘라%' ;

013 비교 연산자 배우기 -4 (IS NULL)

SELECT *
FROM thegifting_personal_matche.erp_product_sku_hst
where is_subscription is null;

014 비교 연산자 배우기 -5 (IN)

SELECT ebut_sku_code,title,type_cd,products_title,real_size
FROM thegifting_personal_matche.erp_product_sku_hst
WHERE real_size IN ('85A','85B','80C') order by real_size;

015 논리 연산자 배우기 (AND, OR,NOT)

SELECT date_no, ad_channel,campaign_name, spend FROM thegifting_personal_matche.daily_ads_log 
WHERE ad_channel ="NAVER" AND spend > 100000 order by spend;