W
W
winmasta2017-05-25 18:39:46
PostgreSQL
winmasta, 2017-05-25 18:39:46

How to sum array field values ​​in postgresql?

Here is a request

with rec as (select "recordId" as rec_id from catalog_12_links where "catalogRecordId"=1) select field7[1] as s from catalog_12_data where "id" in (select rec_id from rec) and field4 = '{2}';

gives this result
s
---
 2
 2
(2 rows)

how to get the sum of these values? and also tell me what exactly to read, so that I myself guessed

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Burov, 2017-05-25
@winmasta

https://www.postgresql.org/docs/current/static/fun... sum

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question