Avatar of Sheldon Livingston
Sheldon Livingston
Flag for United States of America asked on

Pervasive SQL help please

I need a query that returns data where FieldA is blank AND if (FieldB = 'Special' AND FieldC is null)

So I need all records where FieldA is blank.

In addition I need the records where FieldB is equal to the word "Special" and FieldC, on the same record, is null.

Realize that FieldB can contain other words in which I don't care about the status of FieldC.

Any thoughts?
SQL

Avatar of undefined
Last Comment
Sheldon Livingston

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Guy Hengel [angelIII / a3]

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
ste5an

Well, it depends on your definition of blank, doesn't it?

I would guess: WHERE FieldA = '' AND (FieldB = 'Special' AND FieldC IS NULL OR FieldB <> 'Special' ).
Bill Bach

The logic from Guy is right, but change the text [is blank] to [= ''].

Two possible issues:
1-some psql databases use zstring fields, but then populate it with spaces. You may need to provide a string with spaces equal to the field length instead of the empty string.
2-some psql databases do not define null values properly. You may need to use an empty string for the fieldc definition, too.

Both of these are application specific, not database engine specific, so check with your specific data dictionary.
Sheldon Livingston

ASKER
Thank you!
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23