?
Solved

Pervasive SQL help please

Posted on 2016-07-26
4
Medium Priority
?
50 Views
1 Endorsement
Last Modified: 2016-07-26
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?
1
Comment
Question by:classnet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 41729395
then it needs to be OR and not and

fieldA is blank or (FieldB = 'Special' AND FieldC is null)
1
 
LVL 35

Expert Comment

by:ste5an
ID: 41729402
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' ).
0
 
LVL 28

Expert Comment

by:Bill Bach
ID: 41729435
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.
1
 

Author Closing Comment

by:classnet
ID: 41729500
Thank you!
0

Featured Post

Not sure which OpenStack Certification to get?

So you’ve realized you might want to get certified in OpenStack, but you’re not sure what the benefits might be or even which one you should take. You know there are several certification courses you can choose from, but how do you know which one is right for you?

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question