1

In my table I've got a column named facebook with type text[] with array in it. For example:

{{total_count,26861},{comment_count,94},{comment_plugin_count,0},{share_count,26631},{reaction_count,136}}

I'm using my database with datatables and when I'm trying to sort my table by facebook I've got this:

enter image description here

And this is wrong. So I'm trying to get from this array only total_count as numeric value. Now I've got this:

regexp_matches(array_to_string(facebook, ' '), '(\d+).*')

But this returns arrays, for example:

enter image description here

So I've added ::numeric

regexp_matches(array_to_string(facebook, ' '), '(\d+).*')::numeric

but I'm getting an error:

cannot cast type text[] to numeric

Any ideas how to fix it?

2
  • 1
    @lad2025 It was so simple... THANKS A LOT!!! Commented Oct 20, 2017 at 19:35
  • Sure, I posted it as answer :) Commented Oct 20, 2017 at 19:35

1 Answer 1

2

cannot cast type text[] to numeric

You need to cast to numeric[]:

regexp_matches(array_to_string(facebook, ' '), '(\d+).*')::numeric[]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.