Forum Replies Created

Viewing 3 posts - 1 through 4 (of 4 total)

  • RE: Query to calculate average cost

    I have come up with the following:

    SELECT TDate, Units, Price,
     (SELECT SUM(a.Units)
     FROM Table1 a
     WHERE (a.TDate < Table1.TDate)) as CumUnits,
         (CASE WHEN Units > 0 THEN Units*Price ELSE Units*(
          (SELECT...
  • RE: Query to calculate average cost

    Phil/RGR: Thank you both for your ideas - I am studying the arithmetics of it now as you both seem to suggest that there either be a math problem or...

  • RE: Query to calculate average cost

    BaseTable:
    TDate         Units     Price
    30/06/2004  10,000   10
    15/07/2004  2,500     11
    25/07/2004  -1,100    12
    31/07/2004  2,300     11.5
    15/08/2004  -5,000    13
    31/08/2004  1,500      12.5

    Required Output

    TDate         Units     Price    CumUnits Cost Adj.   CumCost   AvgCost
    30/06/2004  10,000   10       10,000    100,000     100,000     10
    15/07/2004  2,500    ...

Viewing 3 posts - 1 through 4 (of 4 total)