Re: string not equal query, postgresql 9.4.4

From: Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at>
To: "'John Scalia *EXTERN*'" <jayknowsunix(at)gmail(dot)com>, "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 08:21:23
Message-ID: A737B7A37273E048B164557ADEF4A58B50FA82A0@ntex2010i.host.magwien.gv.at
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-admin

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

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message John Scalia 2015-09-17 12:18:02 Re: string not equal query, postgresql 9.4.4
Previous Message David G. Johnston 2015-09-17 02:23:11 Re: string not equal query, postgresql 9.4.4