Solved

Pervasive SQL help please

Posted on 2016-07-26
4
34 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
4 Comments
 
LVL 142

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 32

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
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 video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now