Re: sorting of a price field - Mailing list pgsql-novice

From vinayak
Subject Re: sorting of a price field
Date
Msg-id 1379313963507-5771033.post@n5.nabble.com
Whole thread Raw
In response to sorting of a price field  (Anne Wainwright <anotheranne@fables.co.za>)
List pgsql-novice
>I run a fairly simple query to show current records of stock using the
>phrase 'sort by shop_price'.
>Surprise (but really no surprise) this is sorted in ascii order rather
>than shop_price order. So 110.00 comes before 20.00
>I can't see any reference to changing this. What can I do, is this
>perhaps to do with the field type, can it be changed?


may be data type of shop_price is text so you can either type cast it in
below way or alter table and change the data type as numeric(if it is not
violating any other constraints).

select * from table_name order by shop_price::numeric;




-----
Thanks and Regards,
Vinayak Pokale,
NTT DATA OSS Center Pune, India
--
View this message in context: http://postgresql.1045698.n5.nabble.com/sorting-of-a-price-field-tp5770849p5771033.html
Sent from the PostgreSQL - novice mailing list archive at Nabble.com.


pgsql-novice by date:

Previous
From: Lonni J Friedman
Date:
Subject: Re: cannot do backup - locked?
Next
From: Albe Laurenz
Date:
Subject: Re: PostgreSQL 9.3 Error when trying to run Create Extension postgis