Interview Query

Order Addresses

Start Timer

0:00:00

Upvote
21
Downvote
Save question
Mark as completed
View comments (57)
Next question

Given a table of transactions and a table of users, write a query to determine if users tend to order more to their primary address versus other addresses.

Note: Return the percentage of transactions ordered to their home address as home_address_percent.

Example:

Input:

transactions table:

Columns Type
id INTEGER
user_id INTEGER
created_at DATETIME
shipping_address VARCHAR

users table:

Columns Type
id INTEGER
name VARCHAR
address VARCHAR

Example Output:

home_address_percent 0.76
.
.
.
.
.


Comments

Loading comments