The FX feed has NULL rates on some days, sometimes several days in a row. Fill each NULL with the most recent non-NULL rate of the same currency on an earlier date (last observation carried forward). NULLs before a currency's first known rate stay NULL. Return currency, rate_date, filled_rate (ROUND 4) and is_filled (1 when the original rate was NULL and a value was carried forward, else 0). Order by currency, rate_date.
| Column | Type |
|---|---|
| currency | TEXT |
| rate_date | DATE |
| rate | REAL |
| currency | rate_date | rate |
|---|---|---|
| USD | 2026-03-02 | 83.1 |
| USD | 2026-03-03 | NULL |
| USD | 2026-03-04 | NULL |
| USD | 2026-03-05 | 83.25 |
| EUR | 2026-03-02 | 90.5 |
| EUR | 2026-03-03 | 90.75 |
| EUR | 2026-03-04 | NULL |
| currency | rate_date | filled_rate | is_filled |
|---|---|---|---|
| EUR | 2026-03-02 | 90.5 | 0 |
| EUR | 2026-03-03 | 90.75 | 0 |
| EUR | 2026-03-04 | 90.75 | 1 |
| USD | 2026-03-02 | 83.1 | 0 |
| USD | 2026-03-03 | 83.1 | 1 |
| USD | 2026-03-04 | 83.1 | 1 |
| USD | 2026-03-05 | 83.25 | 0 |
Solve it in the live editor on this page — run on sample data, then submit against hidden tests.
‹ Build SCD Type 2 From Daily Snapshots · Frequently Bought Together Pairs ›
{{ totalCount }} questions in the style asked at Amazon, Microsoft, Google, Meta, Flipkart and more — {{ hardPct }}% Hard. Write SQL in a real database engine in your browser, run it on sample data, then evaluate against hidden tests.
Company tags show where this type of question is commonly reported in interviews. Questions, data and solutions are written by TechTown.
{{ cur.statement }}
No submissions yet. Press Evaluate to submit your query.
{{ solutionSql }}
{{ out.error }}
You have solved your 3 free questions — nice work! Log in (free) to unlock all 150 questions, keep your streak and appear on the leaderboard.