Create two arrays for two fields, keeping sort order of arrays in sync (without subquery)
问题 There is no rhyme or reason for this question other than I was curious about how one would go about doing this. Platform: while I was hoping for a SQL-Standard solution, my main concentration is with PostgreSQL 8.4+ . (I know 9.0+ has some array sorting functions.) SELECT id, group, dt FROM foo ORDER BY id; id | group | dt -------+-------+----------- 1 | foo | 2012-01-01 1 | bar | 2012-01-03 1 | baz | 2012-01-02 2 | foo | 2012-01-01 3 | bar | 2012-01-01 4 | bar | 2012-01-01 4 | baz | 2012-01