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...

Advertisement
Free Agile Project Management Tool from Telerik
TeamPulse Community Edition helps your team effectively capture requirements, manage project plans, assign and track work, and most importantly, be continually connected with each other.
Category: SQL | Other Posts: View all posts by this blogger | Report as irrelevant | View bloggers stats | Views: 889 | Hits: 70

Similar Posts

  • SQLAuthority News SQL Server 2012 Upgrade Technical Guide A Comprehensive Whitepaper (454 pages 9 MB) more
  • SQLAuthority News Download Whitepaper Choosing a Tabular or Multidimensional Modeling Experience in SQL Server 2012 Analysis Services more
  • SQL SERVER A Tricky Question and Even Trickier Answer Index Intersection Partition Function more
  • SQLAuthority News Migration Guide: Migrating to SQL Server 2012 Failover Clustering and Availability Groups from Prior Clustering and Mirroring Deployments Part 1 more
  • Free and Easy Export data from SQL/DataTable to XLS, CSV, XML, PDF and Word, HTML, MS clipboard ,DBF, SQL Script, SYLK, DIF, more
  • SQLAuthority News Fast Track Data Warehouse Reference Guide for SQL Server 2012 more
  • SQLAuthority News Select the Best SQL in Sixty Seconds Episode Help us Improve more
  • SQLAuthority News Presenting at Great Indian Developer Summit 2012 SQL Server Misconception and Resolutions more
  • SQLAuthority News Download SQL Azure Labs Codename Data Explorer Client more
  • SQLAuthority News #TechEDIn TechEd India 2012 Things to Do and Explore for SQL Enthusiast more

News Categories

.NET | Agile | Ajax | Architecture | ASP.NET | BizTalk | C# | Certification | Data | DataGrid | DataSet | Debugger | DotNetNuke | Events | GridView | IIS | Indigo | JavaScript | Mobile | Mono | Patterns and Practices | Performance | Podcast | Refactor | Regex | Security | Sharepoint | Silverlight | Smart Client Applications | Software | SQL | VB.NET | Visual Studio | W3 | WCF | WinFx | WPF | WSE | XAML | XLinq | XML | XSD