Country
You are in the Nigeria edition. Type your country to switch.
Nigeria
Loading every country…
No country matches. Check the spelling, or choose "Any country" for the Global edition.
Your learning profile
Financial Data Lab · Lesson 4 of 8
Lab 4: SQL on a price table
This lab builds a small price table in SQLite and answers real questions with SQL: filtering by date and ticker, averages with GROUP BY, joining a company table, and computing daily returns with the LAG window function. Every query is checked against invented data you can verify by hand.
This lesson is complete in writing. A video for it is on its way.
What you will learn
- By the end you can create a price table in SQLite with a primary key on ticker and date, and load sample rows into it.
- You can filter, sort and summarise prices with SELECT, WHERE, ORDER BY and GROUP BY.
- You can join a price table to a company table on a shared key.
- You can compute daily returns and a moving average with window functions, partitioned by ticker.
Key terms in this lesson
- SQL
- Structured Query Language: the standard language for asking a relational database to select, filter, combine and summarise rows of data.
- Window function
- An SQL function that calculates across a set of related rows while keeping each row, such as LAG to read the previous day's price for the same ticker.
- Step 1: Build a small price database, not started
- Step 2: Selecting, sorting and summarising, not started
- Step 3: Joining prices to companies, not started
- Step 4: Returns and moving averages with window functions, not started
- Step 5: SQL and Python together, not started
About 8 min of reading
Step 1 of 5
Build a small price database
Opening this step…
Step 2 of 5
Selecting, sorting and summarising
This step opens when you finish the one above.
Step 3 of 5
Joining prices to companies
This step opens when you finish the one above.
Step 4 of 5
Returns and moving averages with window functions
This step opens when you finish the one above.
Step 5 of 5
SQL and Python together
This step opens when you finish the one above.
Key takeaways
The key takeaways open when you finish every step.
Lesson quiz
6 questions. You need 85% to pass.
The quiz opens when you finish every step.
Read first
Stockertim Learn is education. It explains how investing works and never recommends buying or selling anything.
Popular this week: Basics: BeginnerStock market: Intermediate