2017-10-20 8 views
1

내 테이블에 배열이있는 text [] 유형의 facebook이라는 열이 있습니다. 예를 들어 :배열 값에 의한 Postgres 순서

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

나는 datatables 내 데이터베이스를 사용하고 있는데 나는이있어 페이스 북으로 내 테이블을 정렬하기 위해 노력하고있어 때

enter image description here

을 그리고 이것은 잘못된 것입니다. 그래서이 배열에서 숫자 값으로 total_count 만 얻으려고합니다. 지금이있어 :

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

그러나 이것은 예를 들어, 배열을 반환

enter image description here

그래서 내가 추가 한 ::

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

숫자하지만 난 오류가 발생했습니다 :

cannot cast type text[] to numeric

아이디어를 고치는 방법? 당신은 numeric[]에 캐스트 할 필요가

+1

는 lad2025 @ 너무 간단했다 ... 고마워요! –

+0

예, 답으로 게시했습니다. – lad2025

답변

1

cannot cast type text[] to numeric

는 :

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

그게 전부입니다! 이제 그 일. –

+0

@ DanielKoczuła 내 대답을 수락하는 것을 고려해보십시오 [답변 수락 방법은 무엇입니까?] (http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work/5235#5235) :) – lad2025