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!

Counting with logical fields 1

Status
Not open for further replies.

GKatReliable

Programmer
Jul 2, 2002
45
0
0
US
I am struggling a bit with a line of code I have to modify in a program that generates Cobra letters from an HR system that I support.

I have a series of logical fields in my work database that say which benefit they have for which a letter should be printed. One of them is just plain "Medical". The system change presented to me is a new letter for an HMO in Illinois, so I have a logical field for "Hmoil".

I am counting for Medical=.T. to see if there are any to print this week, but now the people who are .T. for Hmoil should not get the Medical letter, they get their own. My count has to pull in .T. for Medical but exclude .T. for Hmoil. The premise is that earlier in the program and for other reasons, these HMO people are marked .T. for medical to begin with.

If I say:
COUNT TO mcount FOR medical .AND. .NOT. hmoil
then to me this implies it is looking for hmoil = .F., which is not what I want. I am hung up in counting for medical=.T. and exclude hmoil also being true, and the syntax is killing me.

Regards,
Glenn Koproske
 
If I say: COUNT TO mcount FOR medical .AND. .NOT. hmoil
then to me this implies it is looking for hmoil = .F., which is not what I want.
Could you clarify this for me please. I've just read through your posting again and I thought that that was what you did want.

I think that you want to count people who have .T. in the Medical field to show that they need a letter and .F. in the HMoil to show that they're not under the Illinois scheme.

Geoff Franklin
 
All people with medical benefits get .T. for the Medical field.

Additionally, that subset of people with Medical who are enrolled in HMO Illinois get .T. for the Hmoil field.

Everyone who is .T. for hmoil will also be .T. for Medical.

The users say that if we print the letter for Hmoil, the do not need to get the letter for Medical. That means that when we print the letters for Medical, we have to NOT print them for those who are .T. for Hmoil.

Thus, they will be .T. for Medical and at the same time be .T. for Hmoil, but need to be excluded from the count for Medical.

It's kinda like COUNT TO mcount FOR medical=.T. .AND. (somehow exclude hmoil=.T.)



 
Hi,

I think
COUNT TO mcount FOR medical .AND. .NOT. (medical .AND. hmoil)

is the same as
COUNT TO mcount FOR medical .AND. .NOT. hmoil

Try
SELECT medical, hmoil, count(*) ;
FROM yourTable ;
GROUP BY 1,2

to verify your results.
 
One way to figure stuff like this out is with a truth table. It lets you look at the combinations to see if they give you the results you want. For your example, you'd use something like this:

Code:
Medical    HMOIL    Desired   Medical AND NOT HMOIL
  .F.       .F.       .F.       .F.
  .F.       .T.       .F.       .F.
  .T.       .F.       .T.       .T.
  .T.       .T.       .F.       .F.

As you can see, Medical AND NOT HMOIL gives you the desired results.

Tamar
 
Oh yes, I remember truth tables although I don't use them as often as I should. Does anybody remember De Morgan's laws? They were very useful to me over the years.
 
not (P and Q) = (not P) or (not Q)
not (P or Q) = (not P) and (not Q)

Very interesting. On a pop quiz, I would have had both answers reversed.

Regards,
Glenn Koproske
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top