pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: djzanky@gmail.com
To: pgsql-sql@postgresql.org
Subject: Query information needed
Date: 13 Oct 2005 05:50:46 -0700
Message-ID: <1129207846.673463.305670@g44g2000cwa.googlegroups.com> (raw)

Dear all,

I have a table created with this specifications:

CREATE TABLE cdr (
  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
duration.

Any suggestions would be appreciated! Tnx




view thread (3+ messages)  latest in thread

Message-ID: <1129207846.673463.305670@g44g2000cwa.googlegroups.com>
Permalink:  ../1129207846.673463.305670@g44g2000cwa.googlegroups.com/
Also on:    postgresql.org/message-id/1129207846.673463.305670@g44g2000cwa.googlegroups.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: djzanky@gmail.com
  Subject: Re: Query information needed
  In-Reply-To: <1129207846.673463.305670@g44g2000cwa.googlegroups.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox