본문 바로가기
학교 강의/데베기초교양

데베교양 3주차

by hoshi03 2023. 9. 21.

실습사이트 - livesql , https://livesql.oracle.com/apex/f?p=590:1:12681922551238:::RP:: 

 

https://livesql.oracle.com/apex/f?p=590%3A1%3A12681922551238%3A%3A%3ARP%3A%3A

 

livesql.oracle.com

 

SELECT문

 

전체 데이터 조회 select * from 데이터베이스명

 

•정렬 desc - 내림, asc - 올림

id를 기준으로 내림차순 정렬 해서 가져오기

select employee_id, first_name, last_name from hr.employees order by employee_id desc

뒤에 , 조건을 붙이면서 앞에 조건이 동일할때는 어떻게 정렬할지를 정해줄 수 있다

SELECT * from hr.employees where employee_id > 150 order by salary desc, employee_id asc

 

중복 제거 distinct

중복된 행을 제거

select distinct job_id from hr.employees  <- job_id를 중복되지 않게 가져오기

 

별칭 as

테이블을 사용자가 원하는 이름으로 가져오기 select employee_id as 사원번호 from hr.employees

 

• ||(결합 연산자)

select email || '@'  || 'company.com'

from hr.employees;

where email is not null

 

이메일 테이블에 @company.com으로 결합해서 리턴해준다

 

where문은 이어서..

 

 

 

'학교 강의 > 데베기초교양' 카테고리의 다른 글

데베교양 시험대비  (1) 2023.10.23
7주차  (0) 2023.10.12
5주차  (0) 2023.10.06
4주차  (0) 2023.10.01
2주차  (0) 2023.09.15