728x90
use BaseballData;
/*
playerID(선수ID)
yearID(시즌 년도)
teamID(팀 명칭, 'BOS' = 보스턴)
G_batting(출전 경기 + 타석)
AB(타수)
H(안타)
R(출루)
2B(2루타)
3B(3루타)
HR(홈런)
BB(볼넷)
1. 보스턴 소속 선수들의 정보들만 모두 출력
select *
from batting
where teamID is not null and teamID = 'BOS'
2. 보스턴 소속 선수들의 수는 몇명? (단, 중복은 제거)
select COUNT(DISTINCE playerID)
from batting
where teamID is not null and teamID = 'BOS'
1655
3. 보스턴 팀이 2004년도에 친 홈런 개수
select SUM(HR)
from batting
where teamID is not null and teamID = 'BOS' AND yearID = 2004
222
4. 보스턴 팀 소속으로 단일 년도 최다 홈런을 친 사람의 정보.
select MAX(HR)
from batting
where teamID is not null and teamID = 'BOS'
SELECT *
FROM batting
where teamID is not null and teamID = 'BOS' AND HR = 54
정답 원본
SELECT TOP 1*
FROM batting
where teamID = 'BOS'
ORDER BY HR DESC
이 데이터의 원본에 접근
SELECT*
FROM players
where playerID = 'ortizda01'
*/
'공부 > 데이터베이스' 카테고리의 다른 글
INSERT DELETE UPDATE (0) | 2022.01.23 |
---|---|
GROUP BY (0) | 2022.01.22 |
CASE && 집계함수 (0) | 2022.01.16 |
DATETIME (0) | 2022.01.16 |
사칙연산 및 문자열 (0) | 2022.01.15 |