Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help.. report to count rows based on criteria..

Status
Not open for further replies.

jackyzsn

Programmer
May 17, 2007
14
0
0
CA
I have a table like:

Table 1

POL-ID
EFF-DATE
TYP-IND


I need to generate a report like :

Week-Ending Type1 Type2 Type3 Type4
06Jul07 20 10 5 7
13Jul07 15 17 12 4
20Jul07 18 19 1 12
27Jul07 5 10 11 20

Total 58 56 29 43

How can I do that?
 
How about
DEFINE FILE TABLE1
TYPE1/I5 = IF TYP-IND EQ '1' THEN 1 ELSE 0;
TYPE2/I5 = IF TYP-IND EQ '2' THEN 1 ELSE 0;
TYPE3/I5 = IF TYP-IND EQ '3' THEN 1 ELSE 0;
TYPE4/I5 = IF TYP-IND EQ '4' THEN 1 ELSE 0;
END
TABLE FILE TABLE1
SUM TYPE1 TYPE2 TYPE3 TYPE4
BY EFF-DATE AS "WEEK ENDING"
etc

You may have to do some DEFINE with the EFF-DATE to control the SORT.
HTH
 
Also try
TABLE FILE TABLE1
SUM CNT.POLL_ID
ACROSS TYPE_IND
BY EFF_DATE
END
 
Thanks gizzy17. way to go.. I have another question.

How to joint more than two hold files together to get a report?

Use the above sample, I need to generate another report like:

Week-Ending Type1 Type2 Type3 Type4 Received
06Jul07 20 10 5 7 56
13Jul07 15 17 12 4 65
20Jul07 18 19 1 12 45
27Jul07 5 10 11 20 20

Total 58 56 29 43 181

For the column of Received, I can get from another hold file, it has same rows as the first hold file...
 
Putting the Received column on the end would be the difficult part. For this, the easiest solution would be to create a field for each type as jimster had pointed out.

If recieved could be before the across columns then you would just need to join the tables together.

The syntax for the join command is
JOIN keyfld [AND keyfld2 ...] IN hosttable TO [ALL] keyfld [AND keyfld2] IN childtable [AS joinname]
END
The "ALL" keyword would be used if you need a 1-n relationship.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top