Crosstab / Running Sum

I

Ivar Svendsen

Hello

I have one table consisting of three fields

CODE: Tex
DATE: Date/Tim
COUNT: Long intege

The CODE field can be one of three text codes: "TOTAL", "A", and "B". The table contains mostly a mix of the "A" and "B" code lines, (Approx 2-3 a day), and one or two "TOTAL" code lines in a month

I need to create a table that extracts one row for each "TOTAL" record, displaying the date of that "TOTAL" record. In addition, I need two columns "A" and "B" showing the sum of COUNT for all lines with code "A" or "B" that is earlier that the "TOTAL" record being displayed

Example

(Code/Date/Count)
"A"; 1/1/2004;
"B"; 1/1/2004;
"B"; 1/2/2004;
"TOTAL"; 1/3/2004;
"A"; 1/4/2004;
"TOTAL"; 1/5/2004;

Output
(Date/"A"/"B"
1/3/2004; 2;
1/5/2004; 3;

Could anyone please help me on how to best accomplish this

Regards
Ivar Svendsen
 
Top