PostgreSQL - GROUP BY timestamp values?

后端 未结 2 1424
清酒与你
清酒与你 2021-02-18 20:15

I\'ve got a table with purchase orders stored in it. Each row has a timestamp indicating when the order was placed. I\'d like to be able to create a report indicating the numb

2条回答
  •  走了就别回头了
    2021-02-18 21:13

    Grouping by a timestamp column works fine for me here, keeping in mind that even a 1-microsecond difference will prevent two rows from being grouped together.

    To group by larger time periods, group by an expression on the timestamp column that returns an appropriately truncated value. date_trunc can be useful here, as can to_char.

提交回复
热议问题