Recap - Scooter Shop
Coddy SQL 여정의 기초 섹션에 포함된 레슨. 72개 중 41번째.
챌린지
쉬움사용 가능한 테이블 및 열:
<strong>scooters</strong>:<strong>model</strong>,<strong>brand</strong>,<strong>has_lights</strong>,<strong>price</strong>
스쿠터 매장의 매니저로서, 당신은 많은 스쿠터에 모델명이 없어 정품이 아니라는 점을 알아차렸습니다. 게다가 품질이 좋지 않은 스쿠터는 일반적으로 라이트가 없습니다.
작업은 다음 두 단계로 진행됩니다:
- 먼저, 매장에 있는 모든 스쿠터 가격에 전체 평균 가격을 더합니다.
- 그런 다음, 품질이 좋고 정품인 스쿠터(즉, 모델명이 있고 라이트가 있는 스쿠터)만 고려하여 각
brand별 평균 가격을 계산합니다.
결과에는 brand와 평균 가격 avg_price가 포함되어야 합니다. 결과를 평균 가격 기준 오름차순으로 정렬하세요.
직접 해보기
-- 2단계: 재구성된 행을 필터링한 다음, 그룹별로 평균을 구합니다
SELECT ____
FROM (
-- 1단계: 모든 행을 재구성하고, 값을 조정된 값으로 교체합니다
SELECT model, brand, has_lights, ____ AS price
FROM scooters
)
WHERE ____ AND ____
GROUP BY ____
ORDER BY ____기초의 모든 레슨
4More Keywords
The IN keywordThe BETWEEN keywordThe LIKE keywordThe AS keywordRecap - Cellphone Models2Conditions
Conditions BasicsThe AND keywordThe OR keywordThe NOT keywordMultiple Conditions CombinedParenthesisBooleans5Arithmetic Operations
Mathematical OperatorsMathematical ColumnsThe Modulo OperationThe ROUND() Function3Specific Return Format
Null valuesSort Results Part 1Sort Results Part 2Recap - Cyber Security FirmLimit number of recordsRecap - Vehicle Factory6Intro Challenges
Recap - Parliamentary ElectionRecap - Police Criminal ArrestRecap - Bar Beverage ContainerRecap - Engineer new columns직접 연습해 보세요: SQL 플레이그라운드