Hi, I have two tables, one that stores user earnings and another that stores the user payment. What I would like to do is to get payments that are due based on a $50 minimum and only from their last payment.
Table (userEarnings) has the following columns
id ->autoincrement
userid -> unique id for users
earn ->the amount of money the user earn (25.00, 14.50..)
date_added -> DATETIME column
The second table (userPayment) stores each time a user gets paid
pid->autoincrement
uid ->unique user id, this is the same as userid from the above table
paid_amt->payments the user received(500.00, 100.00...)
paid_date ->the date the user was paid(DATETIME)
From those two tables, I would like to list the userid and a sum of the money owed since the last payment if the sum is greater than $50. I assume I will need to use a subquery and group but not sure where to begin.
Any help would be greatly appreciated. Thanks