From: | sqlQuestions <ryanpgodfrey(at)gmail(dot)com> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Conditional Lookup Table with Like |
Date: | 2017-02-17 17:56:01 |
Message-ID: | 1487354161516-5944935.post@n3.nabble.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-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.
From | Date | Subject | |
---|---|---|---|
Next Message | sqlQuestions | 2017-02-17 17:58:57 | Re: Conditional Lookup Table with Like |
Previous Message | David G. Johnston | 2017-02-17 16:41:57 | Re: Conditional Lookup Table with Like |