agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
From: hubert depesz lubaczewski <depesz@depesz.com>
To: Rishi Ranjan <rishiranjan706@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: pgsql-function
Date: Tue, 14 Apr 2015 13:27:03 +0200
Message-ID: <20150414112703.GB2224@depesz.com> (raw)
In-Reply-To: <CALiz8WShL07OjnZySwvmdpYcwDi57JX_WxGSKt69k9kPxLDb8g@mail.gmail.com>
References: <CALiz8WShL07OjnZySwvmdpYcwDi57JX_WxGSKt69k9kPxLDb8g@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-sql>

On Tue, Apr 14, 2015 at 03:39:38AM -0700, Rishi Ranjan wrote:
> i have data like below and where ap_key is same for two different
> first_occurence column . here i need to write a function which can
> calculate the difference of two timestamp values for a Ap_Key and then with
> difference it should multiply the severity

1. Why does it have to be a function? Can't it simply be a query?
2. Which pg version do you use?
3. Which severity to use? from the earlier FIRSTOCCURRENCE, or later, or
   simply higher/lower SEVERITY?

Basically what you're looking for is most likely some group by with
min/max.

depesz

-- 
The best thing about modern society is how easy it is to avoid contact with it.
                                                             http://depesz.com/


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql



view thread (8+ messages)  latest in thread

Message-ID: <20150414112703.GB2224@depesz.com>
Permalink:  ../20150414112703.GB2224@depesz.com/
Also on:    postgresql.org/message-id/20150414112703.GB2224@depesz.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: depesz@depesz.com, rishiranjan706@gmail.com
  Subject: Re: pgsql-function
  In-Reply-To: <20150414112703.GB2224@depesz.com>

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

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