"order by" days of the week

Поиск
Список
Период
Сортировка
От D. A.
Тема "order by" days of the week
Дата
Msg-id 20020928013601.78456.qmail@web13803.mail.yahoo.com
обсуждение исходный текст
Ответы Re: "order by" days of the week  (Oliver Elphick <olly@lfix.co.uk>)
Re: "order by" days of the week  (Roland Roberts <roland@astrofoto.org>)
Список pgsql-novice
Hello,

I am storing a schedule of services in a restaurant database (e.g.
breakfast, lunch...), and want to be able to order the results by the day
of the week. The table is as follows.

                Table "schedule"
   Column    |          Type          | Modifiers
-------------+------------------------+-----------
 business_id | integer                | not null
 day         | character varying(20)  |
 start       | time without time zone |
 finish      | time without time zone |
 service     | character varying(30)  |

The day collumn will hold the days of the week "Monday", "Tuesday"... etc.
When I retrieve the data, I want to be able to sort by the days in
cronological order rather than in alphabetic order.

My questions are these:
1) Is it possible to use "order by" in conjunction with a list of strings
to tell it how to order the results?

2)Is there a way to store days of the week that is better than simply
using varchar and performing a check. I read about the time data formats
and they all seem to be more applicable to absolute times rather than
simply a day of the week. I also thought about storing the days as a
number between 1 and 7 then converting for display (1=Monday,
2=Tuesday...), but that didn't feel clean to me.

Any suggestions?

Thanks,
Doug

__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com

В списке pgsql-novice по дате отправления:

Предыдущее
От: Ludwig Lim
Дата:
Сообщение: Is this error message PostgreSQL related?
Следующее
От: Oliver Elphick
Дата:
Сообщение: Re: "order by" days of the week