Skip to content

Tag: postgresql

Temp sequence in postgres view

I have a table that I order a certain way often. That ordering is the basis of a derived column we can call rank. If I query the entire table, I can have the database calculate that rank for me: This yields useful results like: With that result set I can determine the rank of any foo. However this requires

Group query results by month and year in postgresql

I have the following database table on a Postgres server: I would like to create a query that gives the SUM of the Sales column and groups the results by month and year as follows: Is there a simple way to do that? Answer At the request of Radu, I will explain that query: to_char(date,’Mon’) as mo…