我想选择sql SELECT "year-month" from table group by "year-month" AND order by date:,其中year-month-格式为日期“ 1978-01”,“ 1923-12”。 选择couse work的to_char ,而不是“正确”的顺序:
SELECT "year-month" from table group by "year-month" AND order by date
to_char(timestamp_column, 'YYYY-MM')
date_part(text, timestamp)
例如
date_part('month', timestamp '2001-02-16 20:38:40'), date_part('year', timestamp '2001-02-16 20:38:40')
http://www.postgresql.org/docs/8.0/interactive/functions- datetime.html