Reputation: 555
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
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?
EDIT: 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.
Upvotes: 3
Views: 11135
Reputation: 1271231
Order by
works in Oracle. The problem must be that the results you are getting are different from what you expect.
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)
Upvotes: 8