Average - Pg 9.2

Started by Patrick Babout 9 years ago2 messagesgeneral
Jump to latest
#1Patrick B
patrickbakerbr@gmail.com

Hi guys,

I've got a table which has id and created date columns.

I want to get the average of inserted rows monthly.
How can I get this data?

This query is not working as it is showing me same data in both columns.

select created_date,
AVG(id)
OVER(ORDER BY created_date) AS avr from test

http://sqlfiddle.com/#!15/3289b/1

Thanks!
Patrick

#2David G. Johnston
david.g.johnston@gmail.com
In reply to: Patrick B (#1)
Re: Average - Pg 9.2

On Thursday, February 2, 2017, Patrick B <patrickbakerbr@gmail.com> wrote:

Hi guys,

I've got a table which has id and created date columns.

I want to get the average of inserted rows monthly.
How can I get this data?

This query is not working as it is showing me same data in both columns.

select created_date,
AVG(id)
OVER(ORDER BY created_date) AS avr from test

http://sqlfiddle.com/#!15/3289b/1

Maybe...see GROUP BY...

David J.