Re: casting character varying to integer - order by numeric sort

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bryce W Nesbitt <bryce1(at)obviously(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: casting character varying to integer - order by numeric sort
Date: 2005-10-20 03:33:14
Message-ID: 3687.1129779194@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Bryce W Nesbitt <bryce1(at)obviously(dot)com> writes:
> SELECT username,last_name
> FROM eg_member ORDER BY username::integer;

> But postgres 7 rejects this with "ERROR: cannot cast type character
> varying to integer".

As a general rule, you need to be more specific than that about which
version you are working with ;-)

You may find that username::text::integer will work, depending on which
7.x this actually is.

regards, tom lane

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message tobbe 2005-10-20 06:36:24 automatic update or insert
Previous Message Terry Fielder 2005-10-20 01:34:17 Re: casting character varying to integer - order by numeric