Back to problems

Write SQL using joins and window functions

SQL · Capital One · Medium

You are given two relational tables. accounts holds one row per account, with columns account_id (text, unique), customer_id (text) and segment (text) such as 'gold' or 'silver'. transactions holds one row per transaction, with columns transaction_id (text), account_id (text), amount (numeric) and txn_ts (timestamp). Each transaction is tied to an account, and each account is tied to a customer and a segment. Write one SQL query that, for every segment, returns the customers…

Checking your access…