PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Software Engineering Fundamentals/Robinhood

Write SQL to analyze CA residency history

Last updated: Mar 29, 2026

Quick Overview

This question evaluates a candidate's ability to write SQL for temporal state reconstruction, including correct joins on composite keys, interpreting edit/audit logs, and reasoning about inclusive/exclusive timestamps.

  • hard
  • Robinhood
  • Software Engineering Fundamentals
  • Data Engineer

Write SQL to analyze CA residency history

Company: Robinhood

Role: Data Engineer

Category: Software Engineering Fundamentals

Difficulty: hard

Interview Round: Technical Screen

You have two SQL tables. **Table 1: `user_info`** (current snapshot) - `id` (user id) - `shard` (partition column) - `name` - `country` - `state` - `created_date` **Table 2: `user_info_edit_log`** (edit history) - `id` - `shard` - `created_date` (when the change happened) - `table_name` - `field_name` - `old_value` - `new_value` Assumptions/constraints: - When joining the tables, you must join on **both** `(id, shard)`. - For this question, you can assume `table_name = 'user_info'` and `field_name = 'state'` are the only relevant values (i.e., only state changes for `user_info`). - Output columns for all questions: `(id, shard, name)`. - Interpret **"as of 2021-01-01"** as the user’s state at timestamp `2021-01-01 00:00:00` (inclusive of changes at that instant). Write SQL for each of the following: 1) **Who always lived in CA as of 2021-01-01?** - Meaning: their state on `2021-01-01` is `CA`, and there is no evidence they were ever in a non-CA state before that time. 2) **Who moved to CA before 2021-01-01 and lived in CA as of 2021-01-01?** - Meaning: their state on `2021-01-01` is `CA`, and they changed from a non-CA state to `CA` at some time **strictly before** `2021-01-01`. 3) **Who might have moved out of CA after 2021-01-01?** - Meaning: they were in `CA` as of `2021-01-01`, and there is a state-change record **after** `2021-01-01` indicating `CA -> (not CA)`.

Quick Answer: This question evaluates a candidate's ability to write SQL for temporal state reconstruction, including correct joins on composite keys, interpreting edit/audit logs, and reasoning about inclusive/exclusive timestamps.

Related Interview Questions

  • Explain auth, key rotation, secrets, and incident response - Robinhood (medium)
Robinhood logo
Robinhood
Feb 28, 2026, 12:00 AM
Data Engineer
Technical Screen
Software Engineering Fundamentals
4
0

You have two SQL tables.

Table 1: user_info (current snapshot)

  • id (user id)
  • shard (partition column)
  • name
  • country
  • state
  • created_date

Table 2: user_info_edit_log (edit history)

  • id
  • shard
  • created_date (when the change happened)
  • table_name
  • field_name
  • old_value
  • new_value

Assumptions/constraints:

  • When joining the tables, you must join on both (id, shard) .
  • For this question, you can assume table_name = 'user_info' and field_name = 'state' are the only relevant values (i.e., only state changes for user_info ).
  • Output columns for all questions: (id, shard, name) .
  • Interpret "as of 2021-01-01" as the user’s state at timestamp 2021-01-01 00:00:00 (inclusive of changes at that instant).

Write SQL for each of the following:

  1. Who always lived in CA as of 2021-01-01?
    • Meaning: their state on 2021-01-01 is CA , and there is no evidence they were ever in a non-CA state before that time.
  2. Who moved to CA before 2021-01-01 and lived in CA as of 2021-01-01?
    • Meaning: their state on 2021-01-01 is CA , and they changed from a non-CA state to CA at some time strictly before 2021-01-01 .
  3. Who might have moved out of CA after 2021-01-01?
    • Meaning: they were in CA as of 2021-01-01 , and there is a state-change record after 2021-01-01 indicating CA -> (not CA) .

Solution

Show

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Software Engineering Fundamentals•More Robinhood•More Data Engineer•Robinhood Data Engineer•Robinhood Software Engineering Fundamentals•Data Engineer Software Engineering Fundamentals
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.