VBA Projects

Full Access with Source Code
  • Designed and Developed by PNRao

  • Full Access with VBA Source Code

  • Well Commented Codes Lines

  • Creative and Professional Design

Manage Your Projects

120+ Project Management Templates

Seamlessly manage your projects with our powerful & multi-purpose templates for project management.

120+ PM Templates Includes:
  • 50+ Excel Templates

  • 50+ PowerPoint Templates

  • 25+ Word Templates

Share Post

When we are dealing with huge data, we can not analyse the data by looking into each record. We sort and group the data based on certain variables and understand the data. We use Order By, Group by,Where and Having Clauses to Sort and group the data in SQL.

Following are detailed examples to explain ORDER BY GROUP BY clauses in SQL.

Sorting in SQL:

Order By clause sort the result set from the query (with a where clause) in a specific order using the ORDER BY clause based on specified column(s).


Here is the syntax of Order By clause in SQL.

[code lanuage=”sql”] Select columns
From tables
Where <condition>
Order By column ASC/DSC;

ASC option sort the data in Ascending order and DSC option sort the selected data in Descending Order.


Here is the example to sort the data based on the Department variable. It fetches the data from Employee table and sort the data EID,NAME,Salary,Department based on Department.,[code lanuage=”sql”] SELECT EID,Name,Salary, Department
FROM Employee
ORDER BY Department ASC;

Grouping in SQL:

SQL Group By clause is used to retrieve data grouped according to one or more columns.


Here is the syntax of Group By clause in SQL.

[code lanuage=”sql”] Select columns
From tables
GROUP BY column;


The following example group the data based on Department. It fetches the data from Employee table and sort the data based on Department Variable.[code lanuage=”sql”]

SELECT Department, Sum(Salary)
FROM Employee
GROUP BY Department;

If you want to use Group By with a aggregated function do not use Where Clause, use Having Clause.
The reasons are:
WHERE applies to each and single row and HAVING applies to summarized rows. HAVING clause fetch the data first and then separated according to condition.HAVING is used only with the SELECT statement and WHERE Clause can be used other than Select statement also.WHERE is used before GROUP BY clause, HAVING is used after GROUP BY clause.

Effortlessly Manage Your Projects and Resources
120+ Professional Project Management Templates!

A Powerful & Multi-purpose Templates for project management. Now seamlessly manage your projects, tasks, meetings, presentations, teams, customers, stakeholders and time. This page describes all the amazing new features and options that come with our premium templates.

Project Management Templates

All-in-One Pack
120+ Project Management Templates

Essential Pack
50+ PM Templates

Excel Pack
50+ Excel PM Templates

PowerPoint Pack
50+ Excel PM Templates

MS Word Pack
25+ Word PM Templates

Ultimate Project
Management Template
Ultimate Resource
Management Template
Project Portfolio
Management Templates
Categories: SQLTags: Last Updated: July 1, 2013

Leave A Comment