Total Transactions
Start Timer
0:00:00
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.
Recommended questions for you
Personalized based on your user activity, skill level, and preferences.
.
.
.
.
.
.
.
.
.
Comments