Let's say there is a base:
CREATE TABLE test (
ids integer[]
);
With data
INSERT INTO test VALUES ('{1, 2, 3, 4}');
INSERT INTO test VALUES ('{5}');
I would like to find the number of occurrences of an arbitrary array, say: '{5,1}' in the test database, in what way can this be done?
In my attempts, I could only find the total number of elements in the array, except for those found:
select sum(array_length(array(
(select unnest(ids) except select unnest(array[5,1]))
), 1)) from test;
But, i need exactly the number of occurrences found from the transferred array. How i can find . that?