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.
Solution
Merci pour vos commentaires !
single
Demandez à l'IA
Demandez à l'IA
Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion
Génial!
Completion taux amélioré à 4.55
Challenge: Calculate Running Totals
Glissez pour afficher le menu
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.
Solution
Merci pour vos commentaires !
single