...

/

Solution Review: Top-N Factbook Entries

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 10
select date, shares, trades, dollars
from factbook
where date >= date :'start'
order by date
limit :n;
/***************************************************/

Explanation

The explanation of the code is given below:

  • Line 6: First, we set the start
...