Interview Query

Total Transactions

9
Have you seen this question before?

Write a query to get the cost of all transactions by user ordered by total cost descending.

Example:

Input:

transactions table

Column Type
id INTEGER
user_id INTEGER
created_at DATETIME
product_id INTEGER
quantity INTEGER

products table

Column Type
id INTEGER
name VARCHAR
price FLOAT

users table

Column Type
id INTEGER
name VARCHAR
created_at DATETIME

Output:

Column Type
name VARCHAR
user_id INTEGER
total_cost FLOAT

Note: Round the total cost to 2 decimal places.

Next question: Marketing Channel Metrics
.....
MySQL 8.0.17
Loading editor
Use Shift + Enter to run query