How to Work with GROUP BY Clause in SQL

In this article I am going to explain how to work with GROUP BY Clause in SQL.
  • 2563

Introduction

In this article I am going to explain how to work with  GROUP BY Clause in SQL. GROUP BY clause is used to groups the rows of result set based on one or more columns or expression. GROUP BY clause is used in SELECT statements that include aggregate functions.

To put any condition with group by clause  we use HAVING clause. HAVING clause is used to specify a search condition for a group or an aggregate.

Example

SELECT vendorid, sum(invoicetotal)
as sum_invoicetotal
from mcninvoices
group by vendorid
order by sum_invoicetotal desc

Output

Clipboard12.jpg


© 2020 DotNetHeaven. All rights reserved.