What is the difference between group by and order by?

Answer Posted / visakh viswanath

Difference between order by and group by having ?

suppose i have students table which has id number ,sname
varchar2(20),marks1number ,marks2 number,marks3 number,age
number.

i would like to illustrate what i understood
suppose i want to select students whose id > 2000 and age
>30

my query would be like this
select * from students where id >2000 and age >30 order by
age desc ;
or
else
select * from students group by age ,id having age >30 and
id >2000 ;

so both the queries would be same but in the first one i
use order by followed by my condition in where .
in second once i used group by which would group according
to the age or id and then having is same as where condition
in the above .

Is This Answer Correct ?    3 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a collection in db2?

584


What is alias in db2?

572


How do I change the column size in db2?

593


What is load replace in db2?

560


What is difference between rollback and commit?

634






What is phantom read in db2?

640


How do I add a column to an existing table in db2?

592


Explain in detail about buffer manager and its functionalities?

564


What is runstats and reorg in db2?

800


What is an instance database?

602


How can deadlocks be resolved?

542


Is the primary key a clustered index?

611


What are foreign keys in db2?

616


Which command is used to connect to a database in DB2 ? Give the Syntax.

602


What is the use of db2?

587