Challenge: Calculate Running Totals
Swipe to start coding
Write a SQL query to calculate the running total of expenses over time, using the transactions table. Only include rows where the category is 'Expense'. The results must be ordered by transaction_date. For each row, return the transaction_date, amount, description, and a column named running_total that is the sum of all amount values for expenses from the earliest to the current row (inclusive), ordered by date.
- Filter the
transactionstable to include only rows wherecategoryis'Expense'. - Select the
transaction_date,amount, anddescriptioncolumns. - Calculate a running total of
amountfor each row, ordered bytransaction_date, and include it asrunning_total. - Order the results by
transaction_date.
Рішення
Дякуємо за ваш відгук!
single
Запитати АІ
Запитати АІ
Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат
Чудово!
Completion показник покращився до 4.55
Challenge: Calculate Running Totals
Свайпніть щоб показати меню
Swipe to start coding
Write a SQL query to calculate the running total of expenses over time, using the transactions table. Only include rows where the category is 'Expense'. The results must be ordered by transaction_date. For each row, return the transaction_date, amount, description, and a column named running_total that is the sum of all amount values for expenses from the earliest to the current row (inclusive), ordered by date.
- Filter the
transactionstable to include only rows wherecategoryis'Expense'. - Select the
transaction_date,amount, anddescriptioncolumns. - Calculate a running total of
amountfor each row, ordered bytransaction_date, and include it asrunning_total. - Order the results by
transaction_date.
Рішення
Дякуємо за ваш відгук!
single