Solved

Pervasive SQL help please

Posted on 2016-07-26
4
47 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 500 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 34

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

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

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

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

726 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