By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,109 Members | 1,007 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,109 IT Pros & Developers. It's quick & easy.

unsorted column

shoonya
100+
P: 161
I am having a table where a column contains (integer) contains some numbers in a certain fashion.
now if i only select that column then all the numbers are displayed in sorted way
is there any option to avoid this apart from using a serial key in the table

shoonya
May 30 '07 #1
Share this Question
Share on Google+
3 Replies


Expert 100+
P: 534
I am having a table where a column contains (integer) contains some numbers in a certain fashion.
now if i only select that column then all the numbers are displayed in sorted way
is there any option to avoid this apart from using a serial key in the table

shoonya
Unless you provide the ORDER BY clause the order of result set is not determined, typically you get your records sorted in the way they were inserted (or updated)

If you want to change the default order use the ORDER BY clause where you can specify the desired order, for example
Expand|Select|Wrap|Line Numbers
  1. select column-name from tab-name order by column-name ASC;
  2. select column-name from tab-name order by column-name DESC;
  3. select column-name from tab-name order by random();
  4. select column-one from tab-name order by column-two;
  5.  
Jun 5 '07 #2

shoonya
100+
P: 161
what does this last option do??
Jun 5 '07 #3

Expert 100+
P: 534
what does this last option do??
Expand|Select|Wrap|Line Numbers
  1. SELECT first_name  FROM students ORDER BY last_name;
  2.  
Ordering the result set by a column not included in the select list
Jun 5 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.