MySQL Forums
Forum List  »  Newbie

Check if account has been negative for a period
Posted by: Jan Thøgersen
Date: May 22, 2019 08:24AM

Hi all,

I'm trying to find a way to check if a users account has been negative for a week or more. I need the information to send out payment reminders.

I store the absolute value of the account in a new record for every transaction. I can't be sure that there has been made any records within the past week. Making a query for the period may result in an empty result.

How can I determine if my users account has been negative for a week?

The table:

CREATE TABLE `user_accounts` (
`id` int(10) UNSIGNED NOT NULL,
`user_id` int(10) UNSIGNED NOT NULL,
`by_id` int(10) UNSIGNED DEFAULT NULL,
`transaction_description` char(128) COLLATE utf8_unicode_ci NOT NULL,
`transaction_amount` decimal(10,2) NOT NULL,
`current_balance` decimal(10,2) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;


Thank you in advance!!

/Jan

Options: ReplyQuote


Subject
Written By
Posted
Check if account has been negative for a period
May 22, 2019 08:24AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.