postgres generate array using slide window
问题 I'm trying to figure out how to a query to generate an ARRAY given a sliding window over a character column with Postgre. For example, if I have this: pid <chr> 1 WP_096038768.1 2 WP_013465871.1 3 WP_058155244.1 4 WP_011329269.1 5 WP_058374608.1 6 WP_089368983.1 7 WP_096739105.1 8 WP_089346667.1 9 WP_096041177.1 10 WP_010553306.1 ... I want a sliding window of size 1 before and after the row. The result is this: pid g <chr> <chr> 1 WP_013465871.1 WP_096038768.1,WP_013465871.1,WP_058155244.1 2