Re: Sort of Complex Query - Howto Eliminate Repeating Results

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: Sort of Complex Query - Howto Eliminate Repeating Results
Дата
Msg-id 20060112203531.GA22845@winnie.fuhr.org
обсуждение исходный текст
Ответ на Re: Sort of Complex Query - Howto Eliminate Repeating Results  (<operationsengineer1@yahoo.com>)
Ответы Re: Sort of Complex Query - Howto Eliminate Repeating Results  (<operationsengineer1@yahoo.com>)
Список pgsql-novice
On Thu, Jan 12, 2006 at 12:07:12PM -0800, operationsengineer1@yahoo.com wrote:
> SELECT DISTINCT t_product.product_id,
>        t_product.product_number,
>        t_serial_number.serial_number_id,
>        t_serial_number.serial_number
[...]
> ORDER BY t_serial_number.serial_number::int ASC
>
> resulting error:
>
> ERROR:  for SELECT DISTINCT, ORDER BY expressions must
> appear in select list

What data type is serial_number?  I'm guessing not integer, else
you wouldn't be casting it to integer in the ORDER BY clause.  If
you need that cast then also use it in the SELECT list:

SELECT DISTINCT t_product.product_id,
       t_product.product_number,
       t_serial_number.serial_number_id,
       t_serial_number.serial_number::int

--
Michael Fuhr

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

Предыдущее
От: tmorelli@tmorelli.com.br
Дата:
Сообщение: Re: A question about pages. Now is VERY clear!
Следующее
От:
Дата:
Сообщение: Re: Sort of Complex Query - Howto Eliminate Repeating Results