How to Use ROLLUP Operator with HAVING Clause in SQL

In this article I am going to explain how to use ROLLUP operator with HAVING clause in SQL.
  • 3314


In this article I am going to explain how to Use ROLLUP Operator with  HAVING 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.

WITH ROLLUP operator is used in GROUP BY clause to add summary rows to final result set. Each group specified in GROUP BY clause is summarized by ROLLUP operator.


select vendorid,sum(invoicetotal) as invo_total
from mcninvoices

group by vendorid with rollup




select vendorname,invoiceid,sum(invoicetotal) as invo_total

from mcninvoices join mcnvendors

on mcninvoices.vendorid = mcnvendors.vendorid

where invoicetotal > 500 

group by vendorname,invoiceid with rollup



© 2020 DotNetHeaven. All rights reserved.