From: | John Scalia <jayknowsunix(at)gmail(dot)com> |
---|---|
To: | Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at> |
Cc: | "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org> |
Subject: | Re: string not equal query, postgresql 9.4.4 |
Date: | 2015-09-17 12:18:02 |
Message-ID: | CABzCKRAdrgi+feKz6nCzNx_4P7xDoJ-G+pL3UQ4f9+C+VtGQGQ@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin |
I'm not in front of that server at the moment, so I can't test anything
else, but I should have explained that the result field is char(4) not
null, and all the values in it are length(4), so no padding should exist.
I'll try some of these once I get back home today, but what had me
concerned is if I entered result = 'PASS', as opposed to anything like not
equal, the query worked as expected, and Albe, I believe the wrong syntax
was just my typo from reentering it for the email. Also, David, the reason
I was I searching for anything other than the value 'PASS' is the field has
values of 'FAIL' or a 4 digit hex code produced by the instrumentation
generating the data. I sure didn't want to have to list every possible 4
digit hex value that is a possibility. Sorry I wasn't very clear in my
first posting. I had been struggling with this for some time, and my temper
was a little short.
On Thu, Sep 17, 2015 at 3:21 AM, Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at>
wrote:
> John Scalia wrote:
> > Having a bit of a head-scratching problem. I'm writing a query where I
> want to output only distinct
> > rows where one char(4) field does not equal a specific value. Something
> like:
> >
> > select distinct testname where result <> 'PASS"; #i.e., only the
> FAIL or WARN tests
> >
> > I've tried several different variants like "!~", "not like ('PASS')",
> "is distinct from 'PASS'", and
> > so forth, but obviously I'm missing something as every row is being
> output not
> > just the ones which do not equal PASS. What would be the correct syntax
> for this in a 9.4.4 database?
>
> I observe that your SQL query is syntactically wrong (closing double quote)
> and the FROM clause is missing, but apart from that it should work fine.
>
> Could it be that there are spaces or other invisible characters in the
> "result" attribute?
>
> What do you get for
> SELECT DISTINCT '|' || result || '|' FROM <table> WHERE result <> 'PASS';
>
> Yours,
> Laurenz Albe
>
From | Date | Subject | |
---|---|---|---|
Next Message | John Scalia | 2015-09-17 22:18:42 | Re: string not equal query, postgresql 9.4.4 |
Previous Message | Albe Laurenz | 2015-09-17 08:21:23 | Re: string not equal query, postgresql 9.4.4 |