Re: Sort of Complex Query - Howto Eliminate Repeating Results

From: <operationsengineer1(at)yahoo(dot)com>
To: Michael Fuhr <mike(at)fuhr(dot)org>
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:57:30
Message-ID: 20060112205730.22881.qmail@web33313.mail.mud.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

--- Michael Fuhr <mike(at)fuhr(dot)org> wrote:

> 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
>

Excellent! it worked - thank you very much, Michael.
i would've never made that connection.

serial_number is text. i went that route b/c i
thought i'd never do any math on serial_number. then
i learned how text sorts on numeric data -lol-

as an aside, the forms class i use was only outputting
one instance out of three in the array i created.
three in, one out. this process enabled the
highlighting of unexpected behavior in another piece
of software.

thanks again.

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message me 2006-01-12 23:11:40 storing record-array in varchar?
Previous Message Michael Fuhr 2006-01-12 20:35:32 Re: Sort of Complex Query - Howto Eliminate Repeating Results