SQL Puzzle #1 - Answer
Posted by: JonGalloway.ToString(),
on 02 Nov 2006 |
View original | Bookmarked: 0 time(s)
Here's my solution to the puzzle in my previous post. If you haven't seen the challenge, go back and read that first. My Solution I used 29 lines and 3 temp tables. It's reasonably straightforward - I set up a rank table (#temp), cross join it with the Student table to get ten rows for each student (a cartesian product), then join it to the grades table in order and select out the result. The one little trick is the ranking in the selct for #temp3 - I used the GradeID as the tie-breaker if...