How to query by month?

From: taizi <taizi2006blog(at)163(dot)com>
To: pgsql-admin(at)postgresql(dot)org
Subject: How to query by month?
Date: 2016-11-29 14:08:50
Message-ID: 35257d1c.b253.158b06aaae5.Coremail.taizi2006blog@163.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Hi all,
im a beginner for SQL, and trying to use it with my daily work.
Now i catched this question(my title of mail).
Suppose there is a table about orders, i want to sum the total amount of each month.
There was a statement of mine to november.
select sum(order_amount) FROM table_name WHERE order_date between '2016-11-01' AND '2016-11-30';
I know it comes a result what i want, but i hope someone can tell me another way to use.
After searched, i found there is a function named date_part, but it doesn't work.
thanks for any help!
Leopold

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message xu jian 2016-11-29 15:01:38 can pg 9.6 vacuum freeze skip page on index?
Previous Message Kevin Grittner 2016-11-28 21:47:29 Re: Some questions about old_snapshot_threshold