declare @t table(书编号 int ,读者编号 int) insert into @t select 1,1 union all select 1,2 union all select 2,2 union all select 3,3 union all select 2,3 select count(*)*1.0/count(distinct 读者编号) from @t --1.666666666666
select avg(QTY) from (select count(1) as QTY,Reader from TB group by Reader) a
insert into @t
select 1,1 union all
select 1,2 union all
select 2,2 union all
select 3,3 union all
select 2,3 select count(*)*1.0/count(distinct 读者编号) from @t
--1.666666666666
select avg(QTY) from
(select count(1) as QTY,Reader from TB group by Reader) a
不一定,也可以使用cast转化为小数。