I have a usecase where I want to fetch the latest transaction made by a user on the previous day,
Eg. If today is 26th June 2019,
I want to fetch the last transaction made by the user on 25th June 2019 at 23:59:59
My data is like this -
I'm not good at SQL and tried the following query -
SELECT MAX(transaction_id), user_id, MAX(created_date), new_balance
FROM transaction
where created_date < 1561507199
GROUP BY user_id;
I'm getting the following error -
Error Code: 1055. Expression #4 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'transaction.new_balance' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by