On Mon, 2005-05-16 at 11:47 -0700, David B wrote:
(sorting text columns numerically)
> And of course I get stuff ordered as I want it.
> BUT… with many product categories being numeric based they come out in
> wrong order '10 comes before 2" etc.
>
> So I tried
> Select product_desc, product_
> Is there any elegent query you folks can think of that combines the
> two so I can one query that has alpha sorting on alpha categories and
> numeric sorting on numeric values that are in the same column??
select * from r order by (case when col ~ '^[0-9]+$' THEN lpad(col, 10,
'0') else col end)
Well the following seems to work, althoug I do not believe it is
guarenteed to:
(select * from table where column ~'\\d+' order by cast(colum as integer))
union all
(select * from table where column !~ '\\d+' order by column);
This could be quite slow if table is large
Alternatively:
select * fro
Is there any elegent query you folks can think of that combines the
two so I can one query that has alpha sorting on alpha categories and
numeric sorting on numeric values that are in the same column??
solution 1 (fast)
make a separate column which contains the integer value (updated via a
trigge
Hi All,
I have a tabe
Product_desc varchar(100)
Product_price integer
Product_catvarchar(100)
The problem…
We have categories such as:
Electronics
White Goods
1
2
5
15
25
etc
I have a query
Select product_desc, product_price, product_cat
Order by product_cat, product_price
And of cours