정렬과 연산
USE BaseballData -- 어떤 데이터베이스를 쓸 것인가
SELECT *
FROM players
WHERE birthYear IS NOT NULL
ORDER BY birthYear
USE BaseballData
SELECT *
FROM players
WHERE birthYear IS NOT NULL
ORDER BY birthYear DESC -- 역순정렬
birthYear만 아니라 Month, Day까지 적용해 보자.
USE BaseballData
SELECT *
FROM players
WHERE birthYear IS NOT NULL
ORDER BY birthYear DESC, birthMonth DESC, birthDay DESC
필터 넣기
USE BaseballData
SELECT TOP 10 * -- 상위 10명만 보여달라(참고로 TOP은 MS-SQL 기능임)
FROM players
WHERE birthYear IS NOT NULL
ORDER BY birthYear DESC, birthMonth DESC, birthDay DESC
USE BaseballData
SELECT TOP 1 PERCENT * -- 상위 1%만 보여달라
FROM players
WHERE birthYear IS NOT NULL
ORDER BY birthYear DESC, birthMonth DESC, birthDay DESC
USE BaseballData
SELECT *
FROM players
WHERE birthYear IS NOT NULL
ORDER BY birthYear DESC, birthMonth DESC, birthDay DESC
OFFSET 100 ROWS FETCH NEXT 100 ROWS ONLY
-- 100~200 을 보여달라