Bank Transaction Records
Beginner Mode

Scenario

A bank stores transaction records and customer profiles in separate tables and needs every possible pairing of the two for a coverage analysis.

Task

Write a Snowflake SQL query that:

  1. Performs a CROSS JOIN between {{ ref("transactions") }} and {{ ref("customers") }}, producing every combination of rows
  2. Uses cust_id from the customers table (not from transactions) in the output
  3. Returns all 7 columns: trans_id, trans_amt, date, cust_id, first_name, last_name, age

Schema

transactions

Column Type Description
trans_id Integer Unique transaction identifier
trans_amt Float Amount of the transaction
date String Date the transaction occurred
cust_id Integer Customer ID linked to the transaction

customers

Column Type Description
cust_id Integer Unique customer identifier
first_name String Customer first name
last_name String Customer last name
age Integer Customer age

Example

transactions:

trans_id trans_amt date cust_id
1 250.0 2024-03-01 101
2 780.0 2024-03-02 102
3 120.0 2024-03-03 103

customers:

cust_id first_name last_name age
101 Sarah Blake 34
102 Marcus Chen 28
103 Lily Torres 45

Expected Output (9 rows):

trans_id trans_amt date cust_id first_name last_name age
1 250.0 2024-03-01 101 Sarah Blake 34
1 250.0 2024-03-01 102 Marcus Chen 28
1 250.0 2024-03-01 103 Lily Torres 45
2 780.0 2024-03-02 101 Sarah Blake 34
2 780.0 2024-03-02 102 Marcus Chen 28
2 780.0 2024-03-02 103 Lily Torres 45
3 120.0 2024-03-03 101 Sarah Blake 34
3 120.0 2024-03-03 102 Marcus Chen 28
3 120.0 2024-03-03 103 Lily Torres 45

Note: Every transaction is paired with every customer, producing 3 x 3 = 9 rows. The cust_id in the output comes from the customers table, not transactions.

Quick Solution

Code Environment

Sign in or try as guest to run your code.

Sign In

Track

Question Difficulty Company Access
Need more practice in this area? Explore more questions →