Re: proposal: Preference SQL

Поиск
Список
Период
Сортировка
От Stephen R. van den Berg
Тема Re: proposal: Preference SQL
Дата
Msg-id 20080531090442.GB8631@cuci.nl
обсуждение исходный текст
Ответ на proposal: Preference SQL  (Jan Urbański <j.urbanski@students.mimuw.edu.pl>)
Ответы Re: proposal: Preference SQL  (Jan Urbański <j.urbanski@students.mimuw.edu.pl>)
Список pgsql-hackers
Jan Urba??ski wrote:
>Preference SQL is an extension to regular SQL, that allows expressing 
>preferences in SQL queries. Preferences are like "soft" WHERE clauses. A 
>preference doesn't need to be satisfied by a tuple for it to appear in 
>the result set, but it's "preferred" it is. More strictly, a set of 
>preference clauses in a SQL query defines a partial order on the result 
>set as it would appear without any preference clauses and then returns 
>the maximal elements.

>An example of a preference query would be (quoting the linked PDF):

>SELECT * FROM programmers PREFERRING exp IN (???java???, ???C++???);
>or
>SELECT * FROM computers
>PREFERRING HIGHEST(main_memory) AND HIGHEST(cpu_speed);

Forgive my ignorance, but it appears that this can already be achieved
by using a properly weighted ORDER BY clause, as in:

SELECT * FROM computers
ORDER BY HIGHEST(main_memory) DESC, HIGHEST(cpu_speed) DESC;
-- 
Sincerely,                                                          srb@cuci.nl          Stephen R. van den Berg.

"Sleep: A completely inadequate substitute for caffeine."


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

Предыдущее
От: Simon Riggs
Дата:
Сообщение: Re: Overhauling GUCS
Следующее
От: Jan Urbański
Дата:
Сообщение: Re: proposal: Preference SQL