Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 67367476243 for ; Tue, 6 Aug 2002 13:11:34 -0400 (EDT) Received: from aristote20.infomaniak.ch (aristote20.infomaniak.ch [212.23.249.228]) by postgresql.org (Postfix) with ESMTP id 594BD47663F for ; Tue, 6 Aug 2002 13:10:13 -0400 (EDT) Received: from ced001 (unverified [213.221.146.181]) by aristote20.infomaniak.ch (Rockliffe SMTPRA 4.5.6) with ESMTP id ; Tue, 6 Aug 2002 19:09:52 +0200 From: =?US-ASCII?Q?Cedric_Dufour_=28Cogito_Ergo_Soft=29?= To: "frederic massot" , Subject: Re: SQL syntax Date: Tue, 6 Aug 2002 19:10:11 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) In-reply-to: <3D4FEB4C.3D4D06ED@juliana-multimedia.com> Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200208/110 X-Sequence-Number: 8956 I would try something like SELECT (id_mois+12)%12 FROM ( SELECT id_mois-12 AS id_mois FROM mois UNION SELECT id_mois FROM mois UNION SELECT id_mois+12 AS id_mois FROM mois ) AS mois_etendu WHERE ( mois_etendu.id_mois >= (mon_mois-2) ) AND ( mois_etendu.id_mois <= (mon_mois+9) ) where 'mon_mois' is your reference month (e.g. 8) Cedric Dufour > -----Original Message----- > From: pgsql-sql-owner@postgresql.org > [mailto:pgsql-sql-owner@postgresql.org]On Behalf Of frederic massot > Sent: Tuesday, August 06, 2002 17:29 > To: pgsql-sql@postgresql.org > Subject: [SQL] SQL syntax > > > Hello, > > I have a table containing the months of the year : > > > travail=> select * from mois order by id_mois; > > id_mois|mois_fr |mois_en |mois_de > -------+---------+---------+--------- > 1|Janvier |January |Januar > 2|Fevrier |February |Februar > 3|Mars |March |Marz > 4|Avril |April |April > 5|Mai |May |Aber > 6|Juin |June |Juni > 7|Juillet |July |Juli > 8|Aout |August |August > 9|Septembre|September|September > 10|Octobre |October |Oktober > 11|Novembre |November |November > 12|Decembre |December |Dezember > (12 rows) > > > And I try to obtain for one month given (for example August : 8) two > previous months, the current month, and nine next months : > > > id_mois|mois_fr |mois_en |mois_de > -------+---------+---------+--------- > 6|Juin |June |Juni > 7|Juillet |July |Juli > 8|Aout |August |August > 9|Septembre|September|September > 10|Octobre |October |Oktober > 11|Novembre |November |November > 12|Decembre |December |Dezember > 1|Janvier |January |Januar > 2|Fevrier |February |Februar > 3|Mars |March |Marz > 4|Avril |April |April > 5|Mai |May |Aber > > > Do you see how making in a SQL request ? > > Thank you. > -- > ============================================== > | FREDERIC MASSOT | > | http://www.juliana-multimedia.com | > | mailto:frederic@juliana-multimedia.com | > ===========================Debian=GNU/Linux=== > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org >