Need Formula

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Need a formula that returns Prior Day # - Current Day # for same column, When
Prior is diff record for prior days date.
 
Dear BB:

What you want is probably readily doable, but I cannot give any specifics to
your situation as you have no foundation.

I'm thinking you can already see the Current Day value from your query as it
resides in the current row of the query.

The simplest form (which may not apply to your situation) is:

SELECT MyDate,
(SELECT MAX(MyDate)
FROM MyTable T1
WHERE T1.MyDate < T.MyDate)
AS PrevDate
FROM MyTable T
ORDER BY MyDate

You must fix up table and column names above.

If there are "groups" within the table, and you want the previous date
within the same group:

SELECT MyGroup, MyDate,
(SELECT MAX(MyDate)
FROM MyTable T1
WHERE T1.MyGroup = T.MyGroup
AND T1.MyDate < T.MyDate)
AS PrevDate
FROM MyTable T
ORDER BY MyGroup, MyDate

Do either of these fit your requirements? There are numerous combinations
of complexities in doing this. Without knowing fully or your situation, I
cannot guess at these complexities.

Tom Ellison
 
Thanks Tom, It is set up where:

3.24.06 Column A= #
3.25.06 Column A=# plus Column B#
I want to take:
3.25.06 Column A + Column B less 3.24.06 for Column A's #= Result

Does this clarify it further? Thanks for your help.

BB
 
Back
Top