Recap - Real Estate Contractor
Coddy SQL 여정의 기초 섹션에 포함된 레슨 — 72개 중 51번째.
챌린지
중급사용 가능한 테이블 및 컬럼:
<strong>real_estate</strong>:<strong>asset_id</strong>,<strong>value</strong>,<strong>date</strong><strong>potential</strong>:<strong>asset_id</strong>,<strong>forecast</strong>
일부 분석가들은 부동산 자산의 성장률을 예측합니다. 우리는 그들의 예측이 맞는지 확인하고 싶습니다.
real_estate 테이블의 각 자산에 대해, 더 최근 날짜의 value와 더 이전 날짜의 value 사이의 비율을 계산하세요.
예를 들어, 2022-01-01에 가치가 5였고 2022-05-01에 10이었던 자산이 있다면 그 비율은 10/5 = 2입니다.
두 날짜 간의 일 차이가 101보다 작은 모든 비교를 무시하세요.
각 자산에 많은 날짜가 있으므로 비교할 많은 비율이 있습니다. 각 자산에 대해 가장 큰 비율만 유지하세요.
마지막으로, 이 비율을 potential 테이블의 일치하는 forecast로 나누세요 (이 필드를 ratio_forecast라고 부르세요) 그리고 결과를 내림차순으로 정렬하세요.
최종 결과는 asset_id와 ratio_forecast를 가져야 합니다.
ratio_forecast가 1보다 큰 자산만 유지하세요.
참고: 나누기 연산(/)에서 소수 결과를 얻으려면 분자를 때때로 1.0으로 곱해야 합니다.
예를 들어, a / b 대신 a * 1.0 / b를 사용하여 소수 결과를 얻으세요 (a와 b가 변수일 때)
직접 해보기
기초의 모든 레슨
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 columns9Multiple tables
Basic Join Part 1Basic Join Part 2Recap - JoinSelf joinRecap - Self JoinUnionSimplify queries, WITH keywordRecap - With QueriesRecap - Real Estate Contractor