GeekInterview.com
Series: Subject: Topic:
Question: 88 of 89

How do you sort a table?

Asked by: Interview Candidate | Asked on: Jun 1st, 2005
Showing Answers 1 - 7 of 7 Answers
sangeeta

Answered On : Jun 1st, 2005

we can sort the table by giving asc or desc in order by clause.by default it is desc 
 
eg:select empno,last_name 
from emp 
order by last_name asc;

  
Login to rate this answer.
Muhammad Ali

Answered On : Oct 10th, 2005

Correct it. By defualt order is asc not desc.

  
Login to rate this answer.
manmohan

Answered On : Dec 26th, 2005

no need to write asc because it is by default.

if we want to sort in descending order then we need to specify desc

with the order by command.

  
Login to rate this answer.
Bhawesh

Answered On : Feb 21st, 2006

in order to sort a table we use ORDER BY Clause.

order by clause has basically 2 options ie: asc,desc.

asc: to sort a table in ascending order.

desc: to sort a table in decending order.

By default a table is sorted in ascending order.

eg: select * from [where ]

     orderby <field name1, [field_name2.........]> [asc/desc];

[ ] optional.

  
Login to rate this answer.
quonos

Answered On : May 1st, 2007

Do you mean Select = Ordering table?
It's a question about creating clustered index on table not ordering "data from table" for me.

  
Login to rate this answer.
nalinicisf

Answered On : May 19th, 2008

View all answers by nalinicisf

contents or data of the table can be sorted by using clause ORDER BY  in SELECT statement.

By default the table is in ASCENDING order.

SYN: SELECT  * from [table name]
         where [condition]

         ORDER BY  [column1..] [asc/desc];

Yes  1 User has rated as useful.
  
Login to rate this answer.
dineshctbm

Answered On : Jul 2nd, 2011

View all answers by dineshctbm

Order By is a keyword which is using for sort the table records either ascending or desending.

For eg,

for ascending,
Select emp_name,emp_identity from emp order by emp_identity;
Select emp_name,emp_identity from emp order by emp_identity asc;

for desending,
Select emp_name,emp_identity from emp order by emp_identity desc;

  
Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Ads

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.