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.
Soluzione
Grazie per i tuoi commenti!
single
Chieda ad AI
Chieda ad AI
Chieda pure quello che desidera o provi una delle domande suggerite per iniziare la nostra conversazione
Can you explain this in simpler terms?
What are the main points I should remember?
Can you give me an example?
Fantastico!
Completion tasso migliorato a 4.55
Challenge: Calculate Running Totals
Scorri per mostrare il 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.
Soluzione
Grazie per i tuoi commenti!
single