■ WITH문을 사용하는 방법을 보여준다.
▶ 예제 코드 (SQL)
1 2 3 4 5 6 7 8 9 10 11 12 |
WITH StudentSummary AS ( SELECT COUNT(*) AS TotalStudentCount FROM Student ) SELECT SchoolID AS SchoolID, COUNT(*) AS StudentCount, COUNT(*) * 1.0 / (SELECT TotalStudentCount FROM StudentSummary) AS StudentRatio FROM Student GROUP BY SchoolID; |