按升序排序

时间:2012-12-05 06:35:49

标签: sql oracle plsql oracle-apex

我在Apex中使用了以下POPUP LOV查询

select VEN_INVOICE_REFNO as display_value, VEN_INVOICE_REFNO as return_value 
  from VENDORINVOICE
 order by 1 asc;

我想按照数字顺序i-e按升序显示图中所示的值。我已经尝试了所有可能的方法,但是它不起作用。

enter image description here

5 个答案:

答案 0 :(得分:1)

试试这个::

select VEN_INVOICE_REFNO as display_value, VEN_INVOICE_REFNO as return_value 
  from VENDORINVOICE
 order by ORDER BY CAST(`display_value` AS SIGNED)

答案 1 :(得分:1)

您的字段数据类型似乎是字符串,将其转换为数字然后应用order by

select CAST(VEN_INVOICE_REFNO AS INTEGER) as display_value, VEN_INVOICE_REFNO as return_value 
 from VENDORINVOICE
 order by 1 asc;

答案 2 :(得分:1)

我记得曾经有过这个问题,最后我把它乘以1

类似的东西(不确定它是否可行,你可能需要将你的VEN_INVOICE_REFNO转换成数字)

select (VEN_INVOICE_REFNO * 1) as display_value, VEN_INVOICE_REFNO as return_value 
  from VENDORINVOICE
 order by 1 asc;
像这样:

select CONVERT((VEN_INVOICE_REFNO * 1),UNSIGNED INTEGER) as display_value, VEN_INVOICE_REFNO as return_value 
  from VENDORINVOICE
 order by 1 asc;

答案 3 :(得分:1)

如果任何记录具有非数字值,此处的其他解决方案将无效,因此FWIW是另一种解决方案:

select VEN_INVOICE_REFNO as display_value, VEN_INVOICE_REFNO as return_value 
from VENDORINVOICE
order by LPAD(VEN_INVOICE_REFNO,100,' ') asc;

只需将100更改为列的最大大小。

但是,如果列具有任何负数或十进制(浮点)数值,则我的解决方案将无效。

答案 4 :(得分:0)

试试这个

  

选择VEN_INVOICE_REFNO作为display_value,选择VEN_INVOICE_REFNO作为return_value     来自VENDORINVOICE    按VEN_INVOICE_REFNO排序