agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
From: sqlQuestions <ryanpgodfrey@gmail.com>
To: pgsql-sql@postgresql.org
Subject: Re: Conditional Lookup Table with Like
Date: Fri, 17 Feb 2017 10:56:01 -0700 (MST)
Message-ID: <1487354161516-5944935.post@n3.nabble.com> (raw)
In-Reply-To: <CAKFQuwZx7x7DijFfGzp26zW8PDnv9wrEz2JsS232yyB+VPZmvg@mail.gmail.com>
References: <1487283597419-5944796.post@n3.nabble.com>
	<CAKFQuwYpF146ygOUSXSsAxdAKGsSUXt=a5HtRpUQT=YTy+mwkw@mail.gmail.com>
	<1487286348488-5944801.post@n3.nabble.com>
	<CAKFQuwbdNiN=-ij7Lz0gc6XRwe2cPoVKyc+WH-Z_9+7FR=yj5g@mail.gmail.com>
	<1487345617421-5944908.post@n3.nabble.com>
	<CAKFQuwZx7x7DijFfGzp26zW8PDnv9wrEz2JsS232yyB+VPZmvg@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-sql>

That's pretty cool, I didn't know that one. But I still want to return the
result from table1 when there is null category.

This returns 4 correct results but needs to return the two product_code 3s
with null category:

SELECT table1.product_code, table1.date_signed, table1.description,
COALESCE ((
    SELECT table3.category
    FROM table3
    WHERE table3.psc_code = table1.product_code
    AND lower(table1.description) LIKE ('%' || lower(table3.lookup_value) ||
'%')
  ), table2.category)
FROM table1 JOIN table2 ON table2.psc_code = table1.product_code
WHERE date_signed = '2017-02-01';



--
View this message in context: http://postgresql.nabble.com/Conditional-Lookup-Table-with-Like-tp5944796p5944935.html
Sent from the PostgreSQL - sql mailing list archive at Nabble.com.


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql



view thread (9+ messages)  latest in thread

Message-ID: <1487354161516-5944935.post@n3.nabble.com>
Permalink:  ../1487354161516-5944935.post@n3.nabble.com/
Also on:    postgresql.org/message-id/1487354161516-5944935.post@n3.nabble.com

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: ryanpgodfrey@gmail.com
  Subject: Re: Conditional Lookup Table with Like
  In-Reply-To: <1487354161516-5944935.post@n3.nabble.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox