ORDER BY函数在Oracle中不起作用 [英] ORDER BY function not working in Oracle

查看:1271
本文介绍了ORDER BY函数在Oracle中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在按照以下方式使用ORDER BY函数通过客户ID来订购简单查询(最初是聚会年龄,但是似乎不起作用,因此我对其进行了更改以查看其是否为语法)

I'm using the ORDER BY function as per below to order a simple query by customer id (it was originally party age but that didn't seem to work so I changed it to see if it was the syntax or not).

SELECT   customer_id, customer_name, party_age
FROM     customer
ORDER BY customer_id

该报告没有返回错误,但是当我去查看该报告时,它根本没有排序.我也尝试过使用数字(ORDER BY x).

The report returns no errors, but when I go to view the report it is not ordered at all. I have tried this using numbers as well (ORDER BY x).

有人指导我正确的方向吗?

Anyone guide me in the right direction?

Customer_id是VARCHAR2(3),具有10个示例数据字段,范围从001到010.我尝试按照以下建议转换为int,但结果仍然相同.

Customer_id is VARCHAR2(3) with 10 sample data fields ranging from 001 to 010. I have tried converting to an int as suggested below but the results are still the same.

推荐答案

Order by在Oracle中有效.问题必须是您获得的结果与您期望的结果不同.

Order by works in Oracle. The problem must be that the results you are getting are different from what you expect.

一个典型的原因是将数字表示为字符串.这将命令顺序为1、10、100、101、102. . .如果您期望数字排序,则看起来不正确.

A typical reason for this would be a number that is represented as a string. This would order things as 1, 10, 100, 101, 102 . . . which does not look correct, if you are expecting numeric ordering.

我的猜测是以下方法会起作用:

My guess is that the following would work:

 order by cast(customer_id as int)

这篇关于ORDER BY函数在Oracle中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆