sqlserveråæ³
å建表
create table test
(id int,
name varchar(1))
insert into test values (1,'a')
insert into test values (2,'a')
insert into test values (1,'a')
insert into test values (1,'a')
insert into test values (2,'a')
æ§è¡
select a.id,a.count1,(a.count1+0.0)/b.count2
from
(select id,count(*) count1 from test group by id) a,
(select count(*) count2 from test) b
ç»æ
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/9a504fc2d56285350ade715992ef76c6a7ef6388?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)