in
과 동일한 의미select * form city where population > any ( select population from city where district = "New York");
select * form city where population > some ( select population from city where district = "New York");
→ any가 없으면 서브쿼리에서 값이 여러개가 나와서 에러가 생기는데
any를 사용함으로써 사용가능해진다.
select * form city where population > all ( select population from city where district = "New York");
→ New York에 인구수보다 많은 인구수의 도시를 보여줘라는 의미
select distinct countrycode from city;
출력 개수를 제한
상위의 N개만 출력하는 limit N
구문
서버의 처리량을 많이 사용해 서버의 전반적인 성능을 나쁘게 하는 악성 쿼리문 개선할 때 사용
총합 또는 중간합계가 필요할 경우 사용
group by절과 함께 with rollup문 사용
select countrycode, name, sum(population) from city group by countrycode, name with rollup;
→ null 옆에 써있는 숫자는 위에 있는 것들을 합친 결과값이다.
→ 예를들어, countrycode가 AFG인 null옆에 2332100이란 숫자는
Herat, Kabul, Mazar-e-Sharif, Qandahar을 합친 숫자이다.