Re: Comparing dates in a pattern
От | LALIT KUMAR |
---|---|
Тема | Re: Comparing dates in a pattern |
Дата | |
Msg-id | BANLkTikfNtyeX3zDVPHPYcu6Apz+TkqAzw@mail.gmail.com обсуждение исходный текст |
Ответ на | Comparing dates in a pattern (LALIT KUMAR <lalit.jss@gmail.com>) |
Список | pgsql-novice |
Hi,
The problem as stated by me earlier looks bit clumsy.
I will try to state it in a simple manner.
For a each village:
We see the depth a particular date . If this date lies in any month between (06 to 10 both included) then the depth at this
date must be less than depth at the previous date.
Other wise if the date lies in the month 01 to 05 or 11 to 12 then the depth on these dates must be more than the depth at the previous readings
The problem as stated by me earlier looks bit clumsy.
I will try to state it in a simple manner.
For a each village:
We see the depth a particular date . If this date lies in any month between (06 to 10 both included) then the depth at this
date must be less than depth at the previous date.
Other wise if the date lies in the month 01 to 05 or 11 to 12 then the depth on these dates must be more than the depth at the previous readings
On Sat, Jun 18, 2011 at 5:08 PM, LALIT KUMAR <lalit.jss@gmail.com> wrote:
Hi,I have a table with following sample data:site_id village_name Date depth flagW001 Akoli 1991-01-31 3.5W001 Akoli 1991-03-31 3.7W001 Akoli 1991-05-31 4.35W001 Akoli 1991-09-23 1W001 Akoli 1992-01-31 2.9W001 Akoli 1992-03-31 4W001 Akoli 1992-05-31 4.35W001 Akoli 1992-10-31 2W0002 Awale 1977-05-30 7.2W0002 Awale 1977-10-30 3W0002 Awale 1978-05-30 7.2W0002 Awale 1977-10-30 4.22W003 Talwade 1998-01-23 8W003 Talwade 1998-03-23 9.2W003 Talwade 1998-06-09 8.95W003 Talwade 1998-10-30 1.25W003 Talwade 1999-01-16 0.5The fileds (site_id,date) uniquely identifies a tuple.The date is related to season of rain.For each village the following rules need to be there.A ) The depth in a year from month 01 to 05 increases as for akoli1991-01 : 3.51991-03 : 3.71991-05: 4.35B ) The depth in a year from month 06 to 10 must decrease as compared to previous date depth.1991-09 : 1 when compared to 4.35 of 1991-05If there was reading in 1991-06-,1991-08 then 06 would be compared to 05 and 08 would have been compared to 06.C) The depth in a year from month 11 to 12 must increase as compared to previous date depth.Village Akoli has no reading but other villages may have.Now for next year 1992 the first reading will be compared with last year (1991) last reading and it should be more .1992-01: 2.9Now the depth which violates these rules i need to set the flag field as 1.The last tuple is an example of violation of the rule.There are no fixed months in which depth is measured.No fixed number of readings in a monthNo fixed starting and ending year.
В списке pgsql-novice по дате отправления: