select t.name,count(*) count1,count(*) over() count2 from test t group by t.name;
本来是想获得每一种name的数量,以及总数量。得到的却不是
仔细看了看 count() over()的用法
count() over() 是统计有多少条
正确写法如下:
select t.name,count(*) count1,sum(count(*)) over() count2 from test t group by t.name;