Re: CASE in ORDER BY clause

Поиск
Список
Период
Сортировка
От Uwe C. Schroeder
Тема Re: CASE in ORDER BY clause
Дата
Msg-id 200707091500.52452.uwe@oss4u.com
обсуждение исходный текст
Ответ на Re: CASE in ORDER BY clause  (Lew <lew@lewscanon.nospam>)
Ответы Re: CASE in ORDER BY clause  (Tom Allison <tom@tacocat.net>)
Список pgsql-general
On Saturday 07 July 2007, Lew wrote:

> So if your RDBMS sorts NULLs after all other values, then from
>
> >> select start_date from show_date
> >> order by
> >>   case when start_date > CURRENT_DATE then start_date end desc,
> >>   case when start_date <= CURRENT_DATE then start_date end asc;
>
> all rows with start_date > CURRENT_DATE will appear first, in start_date
> descending order,
> then all rows with start_date <= CURRENT_DATE will appear, in start_date
> ascending order.
>
> Is CURRENT_DATE evaluated once for the query or twice for each row?

CURRENT_DATE is evaluated once per transaction.  If you run in autocommit -
mode, then the single query is wrapped in a transaction by itself.
Either way it's never evaluated per occurrence.

    Uwe

--
Open Source Solutions 4U, LLC    1618 Kelly St
Phone:  +1 707 568 3056        Santa Rosa, CA 95401
Cell:   +1 650 302 2405        United States
Fax:    +1 707 568 6416

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

Предыдущее
От: CG
Дата:
Сообщение: Re: xpath_* namespace bug
Следующее
От: "George Pavlov"
Дата:
Сообщение: Re: dropdb ; createdb equivalent without createdb permission?