我有一张表格如下:
conversation_thread |postid| postType | post_text
AA11 | 1 | Question |'How many whiskers do cats have?'
AA11 | 2 | Reply |"I think on average six"
AA11 | 3 | Reply |"Cats definitely have more than 12 whiskers"
BB11 | 4 | Question |"A cat’s tail is held high means?"
BB11 | 5 | Reply |"The cat is utterly frustrated"
BB11 | 6 | Reply |"An uber happy cat"
我需要按conversation_thread分组,然后展平行。我正在使用postgresql,因此以下查询有效:
select conversation_thread, array_agg(postid),
array_agg(post_text) as text, array_agg(title) as title from myTable
group by conversation_thread;
它输出为:
conversation_thread|postid |post_text
AA11 |{1,2,3}|{"How many whiskers do cats have?","I think on (...)}
BB11 |{4,5,6}|{"A cat’s tail is held high means?", "The cat is (...)}
我没有在post_text字段中获得完整的文本。 我如何获得整个文本而不是(...)