Solution Review: Top-N Factbook Entries
See a detailed analysis of the solution to the "Top-N Factbook Entries" challenge.
We'll cover the following...
Solution
The solution for the challenge is given below. Click the “Run*” button in the following widget to see the output of the code.
Press + to interact
factbook-topn.sql
factbook.csv
/***************************************************//***** The query here to retrieve *****//***** Top-N records from the factbook table *****//***** starting from a specific date *****//***************************************************/\set start '2010-02-04'\set n 10select date, shares, trades, dollarsfrom factbookwhere date >= date :'start'order by datelimit :n;/***************************************************/
Explanation
The explanation of the code is given below:
- Line 6: First, we set the start