M
Meilu
Hello,
I posted this question almost a month ago... and then
misplaced the answer! >_< Sorry...
This is the problem. I have a Table A and Table B
Table A:
Group ID Date Qty
1 Z 1/1/2003 1
2 Z 1/1/2003 1
1 Z 1/2/2003 1
2 Z 1/2/2003 1
1 Z 1/3/2003 1
2 Z 1/3/2003 1
1 Z 1/4/2003 1
2 Z 1/4/2003 1
Table B:
ID Qty
Z 50
B 30
I want a query that will return me the following:
ie: Working with ID Z
ID Date QtyOutstanding
Z 1/1/2003 49
Z 1/2/2003 48
Z 1/3/2003 47
Z 1/4/2003 46
I followed someones advice and made a temporary table
MyTable for calculation purposes. MyTable has the
cooresponding entries of Table A and Table B.
ie: if I was working with ID Z, MyTable would look like
this.
ID Date Qty
Z 1/1/2003 1
Z 1/2/2003 1
Z 1/3/2003 1
Z 1/4/2003 1
Z 1/4/1800 -50
I also have a Query: DetailSum that sums up Table A into:
ID Date QtyOutstanding
Z 1/1/2003 2
Z 1/2/2003 2
Z 1/3/2003 2
Z 1/4/2003 2
The following are two different approaches I tried to
solve my problem. Neither approach really works.
First try:
Select A.ID, A.Date, Sum(MyTable.Qty)
From A, MyTable
Where MyTable.Date <= A.Date and MyTable.ID = A.ID
Group By A.ID, A.Date;
Second try:
Select DetailSum.ID, DetailSum.Date, Sum(MyTable.Qty)
From DetailSum, MyTable
Wehre MyTable.Date <= DetailSum.Date
Group By DetailSum.ID, DetailSum.Date;
Any suggestions on why this isn't working?
Thanks in advance!
Meilu
I posted this question almost a month ago... and then
misplaced the answer! >_< Sorry...
This is the problem. I have a Table A and Table B
Table A:
Group ID Date Qty
1 Z 1/1/2003 1
2 Z 1/1/2003 1
1 Z 1/2/2003 1
2 Z 1/2/2003 1
1 Z 1/3/2003 1
2 Z 1/3/2003 1
1 Z 1/4/2003 1
2 Z 1/4/2003 1
Table B:
ID Qty
Z 50
B 30
I want a query that will return me the following:
ie: Working with ID Z
ID Date QtyOutstanding
Z 1/1/2003 49
Z 1/2/2003 48
Z 1/3/2003 47
Z 1/4/2003 46
I followed someones advice and made a temporary table
MyTable for calculation purposes. MyTable has the
cooresponding entries of Table A and Table B.
ie: if I was working with ID Z, MyTable would look like
this.
ID Date Qty
Z 1/1/2003 1
Z 1/2/2003 1
Z 1/3/2003 1
Z 1/4/2003 1
Z 1/4/1800 -50
I also have a Query: DetailSum that sums up Table A into:
ID Date QtyOutstanding
Z 1/1/2003 2
Z 1/2/2003 2
Z 1/3/2003 2
Z 1/4/2003 2
The following are two different approaches I tried to
solve my problem. Neither approach really works.
First try:
Select A.ID, A.Date, Sum(MyTable.Qty)
From A, MyTable
Where MyTable.Date <= A.Date and MyTable.ID = A.ID
Group By A.ID, A.Date;
Second try:
Select DetailSum.ID, DetailSum.Date, Sum(MyTable.Qty)
From DetailSum, MyTable
Wehre MyTable.Date <= DetailSum.Date
Group By DetailSum.ID, DetailSum.Date;
Any suggestions on why this isn't working?
Thanks in advance!
Meilu