# 去重 下列函数中,有一个实现了合并两个 jsonb 对象并对其去重,是哪一项? ## 答案 ```postgresql create function jsonb_distinct_merge(a jsonb, b jsonb) returns jsonb as $$ select jsonb_agg(distinct (value)) from jsonb_array_elements(a || b) $$ language sql ``` ## 选项 ### A ```postgresql create function jsonb_distinct_merge(a jsonb, b jsonb) returns jsonb as $$ select a || b $$ language sql ``` ### B ```postgresql create function jsonb_distinct_merge(a jsonb, b jsonb) returns jsonb as $$ return jsonb_agg(distinct(value)) from jsonb_array_elements(a||b) $$ language sql ``` ### C ```postgresql create function jsonb_distinct_merge(a jsonb, b jsonb) returns jsonb as $$ return next jsonb_agg(distinct(value)) from jsonb_array_elements(a||b) $$ language sql ``` ### D ```postgresql create function jsonb_distinct_merge(a jsonb, b jsonb) returns jsonb as $$ select a + b; $$ language sql ```