I have a table containing this three field , nodes, Memeber_id, id .there is two repetitive rows of id in entire table. Based on this id value in id column I want to find repetitive value in node array. for eg . -169116 id represents two nodes array {-167486,-49628} and {-43815,-49625,-49626,-49627,-49628} In both the array common value is -49628. so it should select -169116 id and -49628 value from array.
1 Answer
Unnest the array and then simply group by count(node) > 1:
select node, id, count(*)
from (select unnest(nodes) as node, member_id, id from node_test) as g
group by node, id having count(node) > 1;
This results in:
node | id | count
--------+---------+-------
-49628 | -169116 | 2
1 Comment
poonam patel
This is exactly what I wanted @Julia Leder. Thank you
