Skip site navigation (1) Skip section navigation (2)

Problems with query using aggregate functions

From: djzanky(at)gmail(dot)com
To: pgsql-novice(at)postgresql(dot)org
Subject: Problems with query using aggregate functions
Date: 2005-10-13 18:21:34
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
Dear all,

I have a table created with this specifications:

  calldate timestamp with time zone NOT NULL default now(),
  clid varchar(80) NOT NULL default '',
  src varchar(80) NOT NULL default '',
  dst varchar(80) NOT NULL default '',
  dcontext varchar(80) NOT NULL default '',
  channel varchar(80) NOT NULL default '',
  dstchannel varchar(80) NOT NULL default '',
  lastapp varchar(80) NOT NULL default '',
  lastdata varchar(80) NOT NULL default '',
  duration bigint NOT NULL default '0',
  billsec bigint NOT NULL default '0',
  disposition varchar(45) NOT NULL default '',
  amaflags bigint NOT NULL default '0',
  accountcode varchar(20) NOT NULL default '',
  uniqueid varchar(32) NOT NULL default '',
  userfield varchar(255) NOT NULL default ''

I want to extract the number of calls placed in 1 hour and the average
call duration

I'm working with this query:

SELECT date_trunc('hour',calldate), duration FROM cdr WHERE src=601
ORDER BY calldate;

i tried several other queries but i'm not able to count the number of
calls in an hour (better in a time interval) and calculate the average

Any suggestions would be appreciated! Tnx


pgsql-novice by date

Next:From: tövisDate: 2005-10-14 17:16:22
Subject: ecpg - timestamp - howto
Previous:From: Cath LawrenceDate: 2005-10-13 01:33:45
Subject: Re: pg_hba.conf and ssl problem has me stumped

Privacy Policy | About PostgreSQL
Copyright © 1996-2018 The PostgreSQL Global Development Group