N1QL Concatenate many children rows into single string
问题 Consider in Couchbase I have a person database, with 3 documents: Person A Child AA Grand AAA Grand AAB Child AB Grand ABA Grand ABB Person B Person C Child CA Child CB Grand CBA Is there an easy way to turn this into following results using N1QL? I am trying to display each person with their grand children displayed into strings? Person A, Grand: "AAA, AAB, ABA, ABB" Person B, Grand: "" Person C, Grand: "CBA" 回答1: You can do the following: SELECT p.name AS p, ENCODE_JSON(ARRAY_AGG(g.name))