You are on page 1of 1

the order of clauses....

but first there are 4 different clauses that we will use in the dbms part - 2 ....
1. where , 2. order by , 3. group by , 4. having .....

here where and having is used for same but the where clause is can not be used with

aggregate functions like min,max,count,sum,avg,etc.

and the having clause is can be used with the displayed above aggregate
functions....

order by clause is used to display the data in the ascending or the descending
order
the order of order by clause is by default ascending and we manually use the
ascending or descending order
by some add-ons in sql statement like, 'desc' or 'asc' but these statements are
used behind the whole statement
like, "where order by age desc" this done the descending order...

group by clause is used to group the same data so we can easily access the data as
per our need
like we have three student of age 20, two of age 21 and one of age 22
then there will be 3 groups having different ages and now we can easily access the
data of requirements....

the order of these clauses are


1. where
2. group by
3. having
4. order by

if we use these clauses in the wrong order then it will throws an error....

example :: select age,max(marks) from dummytable where age>19 group by age having
max(marks)>85 order by age;

You might also like