From: | "Brent Wood" <b(dot)wood(at)niwa(dot)co(dot)nz> |
---|---|
To: | <user(dot)postgresql(at)gmail(dot)com> |
Cc: | <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Query help |
Date: | 2008-08-15 04:12:18 |
Message-ID: | 48A5AAE20200007B0001495F@gwia1.ham.niwa.co.nz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
If I read this correctly, you want the output sorted by config_id,start_day(day),start_time,
thus:
select config_id, start_day as day, start_time, end_time from config
order by config_id, start_day, start_time;
Cheers,
Brent Wood
>>> novice <user(dot)postgresql(at)gmail(dot)com> 08/15/08 3:55 PM >>>
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
From | Date | Subject | |
---|---|---|---|
Next Message | Dale | 2008-08-15 04:14:43 | syntax error at or near "PERFORM" |
Previous Message | novice | 2008-08-15 03:46:13 | Re: Query help |