Dear Student ,
As per the requirement submitted above , kindly find the below
solution.
ORDER BY
:
- While writing a query whenever
there is requirement to sort the records from the table then Order
By is used.
- Order by clause in sql query is
used to display a row or rows in the table either in ascending
order or descending order.
Syntax : select statement order by
<columnName>
Examples :
- Suppose there is a table which stores information about daily
weather which includes some of the parameters like Humidity for the
day , minimum and maximum temp etc.
- Then to display details of the daily weather in a month and
there is requirement to sort the records based on Humidity either
in ascending order or descending order.
Group By
:
- Group By is used to group identical or similar values existing
in the columns of a table.
- With Group by need to use the aggregate functions provided by
sql.
- Like min(),max(),sum(),count() etc.
- having clause can be used with group by.
Syntax :
- select statements group by <column_name> [Having
clause]
Example :
- Now with the same example need to display weather details in a
month day wise that is like monday,tuesday with min and max temp
etc.
- Then group by can be used
NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE
SOLUTION.