Re: Sort of Complex Query - Howto Eliminate Repeating Results

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: operationsengineer1(at)yahoo(dot)com
Cc: "pgsql-novice(at)postgresql(dot)org" <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Sort of Complex Query - Howto Eliminate Repeating Results
Date: 2006-01-12 20:35:32
Message-ID: 20060112203531.GA22845@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Thu, Jan 12, 2006 at 12:07:12PM -0800, operationsengineer1(at)yahoo(dot)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

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message operationsengineer1 2006-01-12 20:57:30 Re: Sort of Complex Query - Howto Eliminate Repeating Results
Previous Message tmorelli 2006-01-12 20:19:49 Re: A question about pages. Now is VERY clear!