SQL to Calculate Balances
From: Kirk P. (anonymous_at_discussions.microsoft.com)
Date: 02/27/04
- Next message: MGFoster: "Re: Testing to see if a query is open"
- Previous message: MGFoster: "Re: leading zero's were lost"
- Next in thread: MGFoster: "Re: SQL to Calculate Balances"
- Reply: MGFoster: "Re: SQL to Calculate Balances"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 27 Feb 2004 13:46:09 -0800
I have data that looks as follows:
GrantID FiscalYr FiscalQtr TotalNetExp PrdNetExp Balance
8 1998 $5,000.00 $500.00 $4,500.00
8 1999 $5,000.00 $250.00 $4,250.00
8 2000 $5,000.00 $100.00 $4,150.00
8 2001 1 $5,000.00 $300.00 $3,850.00
8 2001 2 $5,000.00 $400.00 $3,450.00
8 2001 3 $5,000.00 $350.00 $3,100.00
8 2001 4 $5,000.00 $300.00 $2,800.00
8 2002 1 $5,000.00 $600.00 $2,200.00
8 2002 2 $5,000.00 $700.00 $1,500.00
8 2002 3 $5,000.00 $200.00 $1,300.00
8 2002 4 $5,000.00 $400.00 $900.00
8 2003 1 $5,000.00 $500.00 $400.00
8 2003 2 $5,000.00 $400.00 $0.00
9 1998 $1,500.00 $800.00 $700.00
9 1999 $1,500.00 $700.00 $0.00
10 1998 $2,500.00 $200.00 $2,300.00
10 1999 $2,500.00 $300.00 $2,000.00
10 2000 $2,500.00 $1,000.00 $1,000.00
10 2001 1 $2,500.00 $700.00 $300.00
10 2001 2 $2,500.00 $300.00 $0.00
I want to be able to calculate a balance for each Fiscal Year/Fiscal Qtr, however sometimes Fiscal Qtr comes in as a null value. The balance calculation needs to start over for each GrantID grouping. Can this be done via a SQL statement?
- Next message: MGFoster: "Re: Testing to see if a query is open"
- Previous message: MGFoster: "Re: leading zero's were lost"
- Next in thread: MGFoster: "Re: SQL to Calculate Balances"
- Reply: MGFoster: "Re: SQL to Calculate Balances"
- Messages sorted by: [ date ] [ thread ]