New answers tagged

2

If you don't have any foreign keys referencing that table (i.e. "incoming" foreign keys), you could do something like this: -- save the squashed data into a temporary table create temp table new_data as SELECT min(date) as date, user_id, sum(usd_value) as usd_value, sum(eur_value) as eur_value from ledger GROUP BY date_trunc('hour', date), user_id; -- get ...


0

Thank you for your prompt reply Akina. MONTH | INCOME | EXPENSES | DIFFERENCE where INCOME represents the sum for all positive values and EXPENSES represents the sum for all negative values per month I have tried the bellow SELECT MONTH(transactiondate) `MONTH`, YEAR(transactiondate) `YEAR`, SUM(CASE when amount <0 then amount END) EXPENSES ,...


1

SELECT SUM(amount) Total_Amount, MONTH(transactiondate) `MONTH`, YEAR(transactiondate) `YEAR` FROM transactionshistory GROUP BY MONTH(transactiondate), YEAR(transactiondate)


Top 50 recent answers are included