J
Johnny
Hi everyone
Hi have a DB were I control the transactions made by a group f people.
The DB has two tables that are related in 1 to many.A table
with people information(name, adress, and so on) and a table with
money transactions.
The transactions table has 6 fields:
- regID related with the ID of "Clients" table (not automatic
counter on transactions table)
-movReg to identify the transaction number(automatic)
-Credits
-Debits
-movDate as date of transaction
-movDescr as description of transaction (food, money deposit,
gas....)
When people join the party they use to add money to personal account.
There is also a common money found, to be used when needed.
Now the problem:
At a certain date for example, someone whose current balance was
$100,
had the need of $200, so he got $100 of is own and $100 of common
found and became $100 negative, that person made two more
transactions
of $100 each and the balance is now $300 negative.
I have a query that will give me all people than has negative balance,
with all the transactions made
since the beginning of the account.
What I need:
In order to advise advise all people that has negative balance,
besides the negative amount, I need the transaction who made the
balance became negative and all other after this one. I Don't need a
list with all transactions.
The idea is just to put in a list of people who are negative, and all
the transactions after the one that let the balance became negative
(included).
In spoken words I'll say:"Mr John you had $100 on your account and
you
pick $200 on date xx/xx/xx, $100 on date xx/xx/xx and more $100 on
date xx/xx/xx, so you are $300 negative"
The query that gives all negative balances and all transactions made:
SELECT MovimentoEuros.MovNum, MovimentoEuros.MovNReg,
MovimentoEurosTesteQuery.strName,
MovimentoEurosTesteQuery.SumOfValorMov
FROM MovimentoEurosTesteQuery INNER JOIN MovimentoEuros ON
MovimentoEurosTesteQuery.MovNReg = MovimentoEuros.MovNReg
WHERE (((MovimentoEurosTesteQuery.SumOfValorMov)<0))
GROUP BY MovimentoEuros.MovNum, MovimentoEuros.MovNReg,
MovimentoEurosTesteQuery.strName,
MovimentoEurosTesteQuery.SumOfValorMov;
On table Debits are saved as negative values and credits as positive.
Hope someone could help
Tks
Hi have a DB were I control the transactions made by a group f people.
The DB has two tables that are related in 1 to many.A table
with people information(name, adress, and so on) and a table with
money transactions.
The transactions table has 6 fields:
- regID related with the ID of "Clients" table (not automatic
counter on transactions table)
-movReg to identify the transaction number(automatic)
-Credits
-Debits
-movDate as date of transaction
-movDescr as description of transaction (food, money deposit,
gas....)
When people join the party they use to add money to personal account.
There is also a common money found, to be used when needed.
Now the problem:
At a certain date for example, someone whose current balance was
$100,
had the need of $200, so he got $100 of is own and $100 of common
found and became $100 negative, that person made two more
transactions
of $100 each and the balance is now $300 negative.
I have a query that will give me all people than has negative balance,
with all the transactions made
since the beginning of the account.
What I need:
In order to advise advise all people that has negative balance,
besides the negative amount, I need the transaction who made the
balance became negative and all other after this one. I Don't need a
list with all transactions.
The idea is just to put in a list of people who are negative, and all
the transactions after the one that let the balance became negative
(included).
In spoken words I'll say:"Mr John you had $100 on your account and
you
pick $200 on date xx/xx/xx, $100 on date xx/xx/xx and more $100 on
date xx/xx/xx, so you are $300 negative"
The query that gives all negative balances and all transactions made:
SELECT MovimentoEuros.MovNum, MovimentoEuros.MovNReg,
MovimentoEurosTesteQuery.strName,
MovimentoEurosTesteQuery.SumOfValorMov
FROM MovimentoEurosTesteQuery INNER JOIN MovimentoEuros ON
MovimentoEurosTesteQuery.MovNReg = MovimentoEuros.MovNReg
WHERE (((MovimentoEurosTesteQuery.SumOfValorMov)<0))
GROUP BY MovimentoEuros.MovNum, MovimentoEuros.MovNReg,
MovimentoEurosTesteQuery.strName,
MovimentoEurosTesteQuery.SumOfValorMov;
On table Debits are saved as negative values and credits as positive.
Hope someone could help
Tks