pgsql-function - Mailing list pgsql-sql

From Rishi Ranjan
Subject pgsql-function
Date
Msg-id CALiz8WShL07OjnZySwvmdpYcwDi57JX_WxGSKt69k9kPxLDb8g@mail.gmail.com
Whole thread Raw
Responses Re: pgsql-function  (hubert depesz lubaczewski <depesz@depesz.com>)
Re: pgsql-function  (hubert depesz lubaczewski <depesz@depesz.com>)
List pgsql-sql
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 

like for 418 time difference is (3/4/2014 0:00 - 3/4/2014/0.05) and it should get multiplied with severity 5 . in this way we need to calculate for every ap_key and store the result in separate table.
AAA_key AP_KEY FIRSTOCCURRENCE  SEVERITY
1114183/4/2014 0:005
1114183/4/2014 0:050
112123/4/2014 0:404
112123/4/2014 0:450
113133/4/2014 1:053
113133/4/2014 1:100
1141143/4/2014 1:302
1141143/4/2014 1:350
115353/4/2014 2:101
115353/4/2014 2:150
1161163/4/2014 10:144
1161163/4/2014 10:190
1171273/4/2014 11:453
1171273/4/2014 11:490
1181183/4/2014 12:102
1181183/4/2014 12:140
119193/4/2014 12:351
119193/4/2014 12:390
1191203/4/2014 0:004
1191203/4/2014 1:400




pgsql-sql by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: Setting the Field Separator in PSQL
Next
From: hubert depesz lubaczewski
Date:
Subject: Re: pgsql-function