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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Count with a Condition

Status
Not open for further replies.

sopomeres

MIS
Jan 16, 2003
61
US
An 'attend' table has 4 fields: student_id, d001, d002, and d003. In the d fields the followng codes are accepted: AE, AU, AT . How can I count the number times each student_id has the "AT" value entered in the three d fields?

Example:
attend.d001 = "AT"
attend.d002 = "AT"
attend.d003 = "AE"

student_id has 2 AT entries

Thanks!
Chuck
 
One way could be to create three separate fields with something like this in each:

shared numbervar countthis1;
if
attend.d001 = "AT"
then
countthis:=1
else
countthis:=0;

A fourth field then adds them all:

shared numbervar countthis1;
shared numbervar countthis2;
shared numbervar countthis3;
countthis1+countthis2+countthis3
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top