Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ORDER BY PROBLEM 10G

Posted on 2011-02-23
13
Medium Priority
?
224 Views
Last Modified: 2012-10-23
Hi,

I have a sort  problem  my queries on 10g.

0
Comment
Question by:venomx_
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
  • 2
  • +2
13 Comments
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 34966496
I'm afraid we'll need a little more information before we can respond.

Maybe the queries, a brief description of the problem?  Something.
0
 

Author Comment

by:venomx_
ID: 34966577
I used to 8.1.5 i didn't have order by problem but I  use 10g I have a peroblem. Query output did not order by sorting. is this optimizer problem?
0
 
LVL 7

Expert Comment

by:MrNed
ID: 34966588
Can you provide an example query? There were changes in Oracle's GROUP BY algorithm which no longer produced sorted output, but it was never guaranteed to anyway without an ORDER BY.
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 34966592
Please post query.

Does the query have an order by?  
What are the columns that aren't being sorted properly?  
What changed?
0
 

Author Comment

by:venomx_
ID: 34966621
select x from yyy group by xx;

xx
----------
3513
353
611
583
631


select x from yyy group by xx order by xx;


xx

-------

011
012
014
015
016
021
032
044
051
0
 
LVL 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 1500 total points
ID: 34966637
As mentioned, the only way to guarantee a specific order is use 'order by'.

You also need to take into account an ASCII sort and number sort.
0
 
LVL 41

Expert Comment

by:Sharath
ID: 34966735
There is no ordering between the records in a table. You have to provide the ORDER BY clause to display the result set in an order. Otherwise there is no guarantee that records will display in same order every time.
0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 34966750
Sharath_123,

Thanks for the post however this has already been mentioned twice before.  Please review previous posts before posting.
0
 
LVL 3

Expert Comment

by:LFLFM
ID: 34974403
Your query seems to be sorted just fine, but here are some considerations:
1. sorting character fields containing number may not sort exactly the way you want or expect, experiment with your results
2. if you want to sort backwards, use the DESC keyword after the field name, in this example, your fieldname is xx: "sort by xx desc"
3. If you have a character field that REALLY contains ONLY numbers and you want to sort as if they were numbers, you can use to_number(xx).... "order by to_number(xx)"

If none of what I said helps you, then you really need to post the problem that you are having and a real example query that actually shows your problem. :-)
0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 34974421
>>Your query seems to be sorted just fine,

It's been posted a lot:  The only way to ensure an order of data in Oracle is with an "ORDER BY".
0
 
LVL 3

Expert Comment

by:LFLFM
ID: 34978926
>>It's been posted a lot:  The only way to ensure an order of data in Oracle is with an "ORDER BY".

Mmm.. I never told him to use order by... he is already using it and seems to be complaining that its not working the way he wants to; (except he didn't explain what, exactly, his problem is) so I sugested ways in which to use his order by's...
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This video shows how to recover a database from a user managed backup

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question