From: | "Duncan Adams (DNS)" <duncan(dot)adams(at)vcontractor(dot)co(dot)za> |
---|---|
To: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: order by int |
Date: | 2002-07-26 14:45:56 |
Message-ID: | AD5E77690E74604B8FCC2BE8C631BC84028435@vodabemail1.vodacom.co.za |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
ur right, for some , dont know what, i thought it as an int field, i now
also find out that it can hold letters as well as numbers, so i guess that
theory out the window.
-----Original Message-----
From: Henshall, Stuart - WCP
[mailto:SHenshall(at)westcountrypublications(dot)co(dot)uk]
Sent: Friday, July 26, 2002 4:16 PM
To: 'Duncan Adams (DNS)'; pgsql-novice(at)postgresql(dot)org
Subject: RE: [NOVICE] order by int
It looks like you are ordering by text rather than a number.
If you need to convert text to a number it can be done like so:
cast('123' AS int4)
so for ordering the query might look like:
select * from tbl order by CAST(text_field AS int4);
hth,
- Stuart
> -----Original Message-----
> From: Duncan Adams (DNS) [ mailto:duncan(dot)adams(at)vcontractor(dot)co(dot)za
<mailto:duncan(dot)adams(at)vcontractor(dot)co(dot)za> ]
> Sent: 26 July 2002 13:26
> To: pgsql-novice(at)postgresql(dot)org
> Subject: [NOVICE] order by int
>
>
> Hi all
>
> quick question
>
> how does one get
> 1
> 2
> 3
> 4
> 5
> 6
> 7
> 8
> 9
> 10
> 11
> instead of
> 1
> 10
> 11
> 2
> 3
> 4
> 5
> 6
> 7
> 8
> 9
> when one does an order by <int>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to
> majordomo(at)postgresql(dot)org)
>
From | Date | Subject | |
---|---|---|---|
Next Message | Jim Steil | 2002-07-26 19:49:30 | Auto-incrementing field |
Previous Message | Henshall, Stuart - WCP | 2002-07-26 14:16:12 | Re: order by int |