473,397 Members | 1,961 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

order by issue

i have the table create with append on option (append on the data to
the end of last page), so suppose the data order is by arrival
sequence. but when i query use select ... order by field1, if the
field1 is same, i couldn't get the right order of the other fields
which is inserted by arrival sequence, and this doesn't happen all the
time, so what problem is this? any solution?
Nov 12 '05 #1
2 2065

<db********@yahoo.com> wrote in message
news:11**************************@posting.google.c om...
i have the table create with append on option (append on the data to
the end of last page), so suppose the data order is by arrival
sequence. but when i query use select ... order by field1, if the
field1 is same, i couldn't get the right order of the other fields
which is inserted by arrival sequence, and this doesn't happen all the
time, so what problem is this? any solution?


This isn't a problem, this is the way DB2 works. In DB2, it has always been
the case - on every platform and DB2 version - that the only way to ensure a
desired sequence for your result set is to use ORDER BY in your query. (In a
few limited cases, GROUP BY or DISTINCT may accomplish the same affect.)

Furthermore, DB2 does not necessarily store data in arrival sequence. In
most cases, the sequence in which data is stored is governed by your choice
of clustering index. (If you have not chosen a clustering index, DB2 will
normally use your oldest existing index as the clustering index.) Even then,
a clustering index does not guarantee that a new row will be stored in
clustering sequence: if the target page for a new row is already full, the
new row will not be stored on the desired page and clustering will,
therefore, not be 100%. In other words, the new row will be stored on some
page other than the desired one and the cluster ratio for that table will no
longer be 100%.

Rhino
Nov 12 '05 #2
Rhino wrote:

<db********@yahoo.com> wrote in message
news:11**************************@posting.google.c om...
i have the table create with append on option (append on the data to
the end of last page), so suppose the data order is by arrival
sequence. but when i query use select ... order by field1, if the
field1 is same, i couldn't get the right order of the other fields
which is inserted by arrival sequence, and this doesn't happen all the
time, so what problem is this? any solution?
This isn't a problem, this is the way DB2 works. In DB2, it has always
been the case - on every platform and DB2 version - that the only way to
ensure a desired sequence for your result set is to use ORDER BY in your
query.


That's actually an SQL thing and not solely bound to DB2.
(In a few limited cases, GROUP BY or DISTINCT may accomplish the
same affect.)


Which you can't rely on, of course. Only ORDER BY defines how rows are
sorted and if there are any duplicates on the ordering columns, then you
can't predict and can't rely on any specific ordering of those rows.

--
Knut Stolze
Information Integration
IBM Germany / University of Jena
Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Andrea | last post by:
Hi, I'm trying to emulate part of our client-server application as a web site so customers can use it, and I'm stuck when it comes to re-ordering items in a list. Basically we have a list of...
3
by: pyda001 | last post by:
Hi! We are working on a webshop issue and are facing the following problem. Chances are that this has been solved before and thus we don't need to reinvent the wheel. Our website is supposed...
9
by: sdbranum | last post by:
Tab pages, which I have added to forms in design view, are occassionally reordered without warning. Other than hard-coding the tab order by clearing then readding these same tab pages outside...
104
by: Beowulf | last post by:
I have the view below and if I use vwRouteReference as the rowsource for a combo box in an MS Access form or run "SELECT * FROM vwRouteReference" in SQL Query Analyzer, the rows don't come through...
29
by: pb648174 | last post by:
I have the following basic statements being executed: Create a temp table, #TempPaging Insert Into #TempPaging (Col1, Col2) Select Col1, Col2 From SomeOtherTable Order By Col2, Col1 Select...
9
by: John Rivers | last post by:
Hello, if you create this table: create table hello ( int a , int b constraint pk_hello primary key clustered ( a, b ) )
6
by: p_adib | last post by:
hello. I have 3 files: parent.cpp child.cpp driver.cpp I am working in visual C++ 6.0 and have all the files in one same project. When I ask the IDE to biuld my project, it compiles the code...
54
by: Rasjid | last post by:
Hello, I have just joined and this is my first post. I have never been able to resolve the issue of order of evaluation in C/C++ and the related issue of precedence of operators, use of...
2
geolemon
by: geolemon | last post by:
I'm having a frustrating issue with a report that WON'T order my data properly, seemingly whatever I do. Surely I must be overlooking something! I have an "order by" in my raw query: SELECT...
11
Dormilich
by: Dormilich | last post by:
Hello, I'm trying to validate my XML files against a DTD with PHP 5 and it spits out element order errors (see below). the files validate in FF (once I set the used entities in the local DTD part,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.