pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: novice <user.postgresql@gmail.com>
To: pgsql-general@postgresql.org
Subject: Query help
Date: Fri, 15 Aug 2008 10:32:38 +1000
Message-ID: <ddcb1c340808141732q4e2f36b9s40a02c702d7323f9@mail.gmail.com> (raw)

Hi,
I have a table

select id, config_id, start_day, end_day, start_time, end_time from config;

 id  | config_id | start_day | end_day | start_time | end_time
-----+-----------+-----------+---------+------------+----------
   1 |       101 | Mon       | Sun     | 08:30:00   | 18:00:00
   2 |       101 | Mon       | Sun     | 18:00:00   | 22:00:00
   3 |       555 | Mon       | Fri     | 08:30:00   | 16:00:00



I'd like to write a query to generate the following... is it possible at all?

 config_id | day       | start_time | end_time
-----------+-----------+---------+-------------
       101 | Mon       | 08:30:00   | 18:00:00
       101 | Mon       | 18:00:00   | 22:00:00
       101 | Tue       | 08:30:00   | 18:00:00
       101 | Tue       | 18:00:00   | 22:00:00
       101 | Wed       | 08:30:00   | 18:00:00
       101 | Wed       | 18:00:00   | 22:00:00
       101 | Thu       | 08:30:00   | 18:00:00
       101 | Thu       | 18:00:00   | 22:00:00
       101 | Fri       | 08:30:00   | 18:00:00
       101 | Fri       | 18:00:00   | 22:00:00
       101 | Sat       | 08:30:00   | 18:00:00
       101 | Sat       | 18:00:00   | 22:00:00
       101 | Sun       | 08:30:00   | 18:00:00
       101 | Sun       | 18:00:00   | 22:00:00
       555 | Mon       | 08:30:00   | 18:00:00
       555 | Tue       | 08:30:00   | 18:00:00
       555 | Wed       | 08:30:00   | 18:00:00
       555 | Thu       | 08:30:00   | 18:00:00
       555 | Fri       | 08:30:00   | 18:00:00

Thanks



view thread (70+ messages)  latest in thread

Message-ID: <ddcb1c340808141732q4e2f36b9s40a02c702d7323f9@mail.gmail.com>
Permalink:  ../ddcb1c340808141732q4e2f36b9s40a02c702d7323f9@mail.gmail.com/
Also on:    postgresql.org/message-id/ddcb1c340808141732q4e2f36b9s40a02c702d7323f9@mail.gmail.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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: user.postgresql@gmail.com
  Subject: Re: Query help
  In-Reply-To: <ddcb1c340808141732q4e2f36b9s40a02c702d7323f9@mail.gmail.com>
  References: <ddcb1c340808141732q4e2f36b9s40a02c702d7323f9@mail.gmail.com>

* 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