Re: Ordering problem with varchar (DESC)

Поиск
Список
Период
Сортировка
От Alexandre Leclerc
Тема Re: Ordering problem with varchar (DESC)
Дата
Msg-id 45C0E2CD.4000701@ipso.ca
обсуждение исходный текст
Ответ на Re: Ordering problem with varchar (DESC)  ("Brandon Aiken" <BAiken@winemantech.com>)
Список pgsql-general
Brandon Aiken a écrit :
> As others have said, VARCHAR is the incorrect data type to be using
> here.  You should either be using INTERVAL or TIMESTAMP depending on
> what you want.  You can even combine date and time into a single
> TIMESTAMP field.  Only use VARCHAR when no other data type will do.

I dearly would like to do that, but it is impossible (because of the
software/technology that uses the database). I would have use a
TIMESTAMP for that.

> Try "SELECT * from t1 ORDER BY date, time;", and I suspect you will get:
> date (date type)  time (varchar)  data
> 2007-01-17         8h40           d1
> 2007-01-30        12h00           d3
> 2007-01-30        13h45           d4
> 2007-01-30        17h20           d5
> 2007-01-30         9h30           d2
>
> To use your current schema, you need to zero-fill your hours, so 9h30
> needs to be 09h30 and so forth.

Exactly. This is sorted that way. This is what I'll do, inserting a 0.

Best regards.

--
Alexandre Leclerc

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

Предыдущее
От: Jeff Davis
Дата:
Сообщение: Re: Any Plans for cross database queries on the same server?
Следующее
От: Alexandre Leclerc
Дата:
Сообщение: Re: Ordering problem with varchar (DESC)