[내일배움캠프] SQL 정리

문인·2025년 10월 21일
0
  1. 오늘 학습 키워드
    컬럼에 별명 붙이기
    where절 사용법
    계산하기
  2. 오늘 학습 한 내용을 나만의 언어로 정리하기

컬럼에 별명 붙이기
select order_id ord_no, name "이름"
특수문자, 한글/ "이름"
영어, 언더바/ 띄어쓰기

where절 사용법

select *
from customers
where age=21
=, <, >, <>

between a and b
in (21, 25, 27)
like '김%'
     '%next%'
     '%임'

숫자 연산 (+,-,*,/)
select food_preparation_time,
   delivery_time,
   food_preparation_time + delivery_time 
from food_orders

합계, 평균(sum,avg)
select sum(food_preparation_time),
   	avg(delivery_time) 
from food_orders

갯수 (count(1) 1과 *은 전체를 의미, distinct는 종류를 의미)
select count(1) count_of_orders,

count(distinct customer_id) count_of_customers
from foodorders

최솟값, 최댓값 (min,max)
select min(price),
       max(price) 
from food_orders
  1. 학습하며 겪었던 문제점 & 에러 X

  2. 내일 학습 할 것은 무엇인지
    group by절 부터

#내일배움캠프 #TIL

0개의 댓글