[SQLD] 핵심요약 (2)
조건문Decode- select decode(col1,'A',1,'B',2,3) from dual; (col이 A면 1, B면 2, 아니면 3) case- case when col = 'A' then 1 when col = 'B' then 2 else 3 end;- case col when 'A' then 1 when 'B' then 2 else 3 end;집계함수- Count, min sum, max 등- null은 포함되지 않음 - (1, null, 2, 3, null) 의 데이터를 기준으로 결과는 다음과 같음- Count() : 3- Sum() : 6- Avg() : 2- Min() : 1- Max() : ..
[SQLD] 핵심요약 (1)
SQL 연산순서- From- Where- Group by- Having- Select- Order byDML- Select, Insert, Update, Delete DDL- Alter, Create, Modify, Drop TCL- Rollback, Commit DCL- Grant, RevokeDISTINCT: 컬럼값들의 중복 제거 한 결과 출력- Select distinct col from table;- Select distinct col1, col2 from table; (col1과 col2의 값이 모두 같지 않은 것만 출력)Alias- Select 절에서 사용가능, where 절에서는 사용 불가- Select col as name from table; = select col name from ta..