Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id E63D8650467 for ; Thu, 14 Aug 2008 21:41:42 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 00457-03-6 for ; Thu, 14 Aug 2008 21:41:21 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from wa-out-1112.google.com (wa-out-1112.google.com [209.85.146.179]) by postgresql.org (Postfix) with ESMTP id D6D226503AE for ; Thu, 14 Aug 2008 21:32:40 -0300 (ADT) Received: by wa-out-1112.google.com with SMTP id n4so361207wag.5 for ; Thu, 14 Aug 2008 17:32:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender :to:subject:mime-version:content-type:content-transfer-encoding :content-disposition:x-google-sender-auth; bh=rqm58EOUFOifq1nEGEx+pcdgOOUlYqGpJ0JUGcTDDv4=; b=vcO1IMXGMV+bxnOE15YdPoTHL/V4O03yK+3BzpXoeJUwZx+1qq47rLafP7GV5DjarQ pDzjZNvaR1jDyh79w6MDXmSpxBreDT/xn3EFrKF+ZH74jncaj1dEHK+qcRsJzbYJBC4v GuDW7WiYXwp0Oe0y4BUAXpLA2eIKk9L0oHeBo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:mime-version:content-type :content-transfer-encoding:content-disposition:x-google-sender-auth; b=mjChqNOo9h4idsi3Pz0sxgziBOgXxUZVTJHViKnYOm6u1h5j1GD1ot1l6Iiw9BX9SD 2QemfxiTvQGZwCRQYob3FuPpM+xn3LHhkGVVew8kybPgeYOeLC738UkbiwKWahagxxs6 4YpbOon+niCQc8DmXA/G0PvRlOxWc0B2FajKE= Received: by 10.115.33.1 with SMTP id l1mr2020808waj.115.1218760358804; Thu, 14 Aug 2008 17:32:38 -0700 (PDT) Received: by 10.114.81.15 with HTTP; Thu, 14 Aug 2008 17:32:38 -0700 (PDT) Message-ID: Date: Fri, 15 Aug 2008 10:32:38 +1000 From: novice To: pgsql-general@postgresql.org Subject: Query help MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Google-Sender-Auth: d77d685b945f9704 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200808/510 X-Sequence-Number: 136340 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