postgresql - Set value in select statement -


i have 2 views , b created other views (cant use rule on update instead). , b have same 3 columns text_1, text_2, count. till sql looks like:

select a.text_1, a.text_2, coalesce(b.count,a.count) count      left join b on a.text_1 b.text_1 , a.text_2 b.text_2; 

but need rule set value of count 0 of records text_1 text_2 in result of select statement above.

i'm using views because use "create or replace..." statement.

using make simpler , cast boolean integer avoids verbose case

select     text_1, text_2,     coalesce(b.count, a.count) * (not text_1 = text_2)::int count           left join     b using (text_1, text_2) 

Popular posts from this blog

Apache NiFi ExecuteScript: Groovy script to replace Json values via a mapping file -

node.js - How do I prevent MongoDB replica set from querying the primary? -

python 3.x - PyQt5 - Signal : pyqtSignal no method connect -