Count number of records returned by group by

前端 未结 13 1844
梦毁少年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:30

    You can do both in one query using the OVER clause on another COUNT

    select
        count(*) RecordsPerGroup,
        COUNT(*) OVER () AS TotalRecords
    from temptable
    group by column_1, column_2, column_3, column_4
    

提交回复
热议问题