pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jean-Luc Lachance <jllachan@nsd.ca>
To: frederic massot <frederic@juliana-multimedia.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: SQL syntax
Date: Tue, 06 Aug 2002 13:38:25 -0400
Message-ID: <3D500991.78527FD5@nsd.ca> (raw)
References: <3D4FEB4C.3D4D06ED@juliana-multimedia.com>

Try:

Order by mod( id_mois + 12 - <current_month>, 12)

frederic massot wrote:
> 
> 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



view thread (11+ messages)  latest in thread

Message-ID: <3D500991.78527FD5@nsd.ca>
Permalink:  ../3D500991.78527FD5@nsd.ca/
Also on:    postgresql.org/message-id/3D500991.78527FD5@nsd.ca

 · 

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: jllachan@nsd.ca, frederic@juliana-multimedia.com
  Subject: Re: SQL syntax
  In-Reply-To: <3D500991.78527FD5@nsd.ca>

* 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