Count number of records returned by group by

前端 未结 13 1838
梦毁少年i
梦毁少年i 2020-11-30 20:01

How do I count the number of records returned by a group by query,

For eg:

select count(*) 
from temptable
group by column_1, column_2, column_3, co         


        
13条回答
  •  心在旅途
    2020-11-30 20:37

    I was trying to achieve the same without subquery and was able to get the required result as below

    SELECT DISTINCT COUNT(*) OVER () AS TotalRecords
    FROM temptable
    GROUP BY column_1, column_2, column_3, column_4
    

提交回复
热议问题