A
Angela
Hi,
I'm working with a table in which I have following fileds.
DATE
NUM
AMOUNT
RECEIPT#
AMOUNT2
Basically have to return latest line against NUM after below
calculations.
In case of a reversal, a similar line is posted with different date
usually next day, a new receipt# and amount in either amount columns
is -ve.. for instance if it was 50, then reversal line becomes -50 in
either column.
In such case, numwise, the query should not return any line since all
transactions are now reversed.
In case of a third and correct entry, the query should return this
third line with its row details.
In case of another reversal of same, the query should be blank and so
on...
The problem is that I'm using max on date & last for all the fields
but still getting lines for which there are single reversal posted.
The query is unable to check the pairing.
What I want in the query is all single entries(those without
reversals), all those entries which go through reversals, calculate
the valid entry from those reversals by grouping them and getting the
final clean entry if any.
Examples:
DATE| NUM| AMOUNT| RECEIPT| AMOUNT2
------------------------------------------
1/10/2009 777 299 00019 0
1/10/2009 123 199 00024 0
1/10/2009 444 0 00026 199
3/10/2009 123 -199 00028 0
should get
1/10/2009 777 299 00019 0
1/10/2009 444 0 00026 199
--------------------------------------------
1/10/2009 777 299 00019 0
1/10/2009 123 199 00024 0
1/10/2009 444 0 00026 199
3/10/2009 123 -199 00028 0
3/10/2009 123 199 00031 0
should get
1/10/2009 777 299 00019 0
1/10/2009 444 0 00026 199
3/10/2009 123 199 00031 0
--------------------------------------------
1/10/2009 777 299 00019 0
1/10/2009 123 199 00024 0
1/10/2009 444 0 00026 199
3/10/2009 123 -199 00028 0
3/10/2009 123 199 00031 0
16/10/2009 123 -199 00045 0
17/10/2009 444 0 00046 -199
should get
1/10/2009 777 299 00019 0
---------------------------------------------
1/10/2009 777 299 00019 0
1/10/2009 123 199 00024 0
1/10/2009 444 0 00026 199
3/10/2009 123 -199 00028 0
3/10/2009 123 199 00031 0
16/10/2009 123 -199 00045 0
17/10/2009 444 0 00046 -199
21/10/2009 123 0 00068 199
21/10/2009 444 199 00096 0
should get
1/10/2009 777 299 00019 0
21/10/2009 123 0 00068 199
21/10/2009 444 199 00096 0
Hope the examples are clear enough.
Anyhelp is appreciated greatly.
Angela.
I'm working with a table in which I have following fileds.
DATE
NUM
AMOUNT
RECEIPT#
AMOUNT2
Basically have to return latest line against NUM after below
calculations.
In case of a reversal, a similar line is posted with different date
usually next day, a new receipt# and amount in either amount columns
is -ve.. for instance if it was 50, then reversal line becomes -50 in
either column.
In such case, numwise, the query should not return any line since all
transactions are now reversed.
In case of a third and correct entry, the query should return this
third line with its row details.
In case of another reversal of same, the query should be blank and so
on...
The problem is that I'm using max on date & last for all the fields
but still getting lines for which there are single reversal posted.
The query is unable to check the pairing.
What I want in the query is all single entries(those without
reversals), all those entries which go through reversals, calculate
the valid entry from those reversals by grouping them and getting the
final clean entry if any.
Examples:
DATE| NUM| AMOUNT| RECEIPT| AMOUNT2
------------------------------------------
1/10/2009 777 299 00019 0
1/10/2009 123 199 00024 0
1/10/2009 444 0 00026 199
3/10/2009 123 -199 00028 0
should get
1/10/2009 777 299 00019 0
1/10/2009 444 0 00026 199
--------------------------------------------
1/10/2009 777 299 00019 0
1/10/2009 123 199 00024 0
1/10/2009 444 0 00026 199
3/10/2009 123 -199 00028 0
3/10/2009 123 199 00031 0
should get
1/10/2009 777 299 00019 0
1/10/2009 444 0 00026 199
3/10/2009 123 199 00031 0
--------------------------------------------
1/10/2009 777 299 00019 0
1/10/2009 123 199 00024 0
1/10/2009 444 0 00026 199
3/10/2009 123 -199 00028 0
3/10/2009 123 199 00031 0
16/10/2009 123 -199 00045 0
17/10/2009 444 0 00046 -199
should get
1/10/2009 777 299 00019 0
---------------------------------------------
1/10/2009 777 299 00019 0
1/10/2009 123 199 00024 0
1/10/2009 444 0 00026 199
3/10/2009 123 -199 00028 0
3/10/2009 123 199 00031 0
16/10/2009 123 -199 00045 0
17/10/2009 444 0 00046 -199
21/10/2009 123 0 00068 199
21/10/2009 444 199 00096 0
should get
1/10/2009 777 299 00019 0
21/10/2009 123 0 00068 199
21/10/2009 444 199 00096 0
Hope the examples are clear enough.
Anyhelp is appreciated greatly.
Angela.