array(select
unnest(
array['12', '34', '56', 'NULL'])
except select unnest(
array['AA', 'cc', 'P4', 'G8']
)) as modifiers
I'm getting the result array as - [NULL,56,12,34], order is messed up after comparing the 2 arrays. I want the result to be in same order of "first" array - ['12', '34', '56', 'NULL']. Is there any way to get that?
What I'm trying to do here is, I want to fetch all unmatched elements from first array in same order. In above example none of them are matching, so we are getting all the elements from first array as it is, which is correct. But it should be in same order of first array.
Another example:
array(select
unnest(
array['12', '34', '56', 'NULL'])
except select unnest(
array['AA', 'cc', 'P4', '34']
)) as modifiers
Expected result: ['12', '56', 'NULL']