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.
Ratkaisu
Kiitos palautteestasi!
single
Kysy tekoälyä
Kysy tekoälyä
Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme
Mahtavaa!
Completion arvosana parantunut arvoon 4.55
Challenge: Calculate Running Totals
Pyyhkäise näyttääksesi valikon
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.
Ratkaisu
Kiitos palautteestasi!
single