select count(*) as 记录数 from (select count(distinct IDnum ) as n17,count(IDnum) b from employer where IDnum <> ' ' group by IDnum having count(IDnum)>1 )a
select a.n17 ,count(a.n17) from ( select IDnum ,count(*) as n17 from employer where IDnum <> ' ' group by IDnum having count(*)>1 order by IDnum compute sum(count(*)) ) a group by a.n17
C#的话 就用Datatable读出来就行了 datatable dt= new DataTable() SqlDataAdapter sda = new SqlDataAdapter(sqlString,con); sda.Fill(dt); int a= System.Convert.ToInt16(dt.Rows[i]["n17"].ToString());
from
(select count(distinct IDnum ) as n17,count(IDnum) b from employer where IDnum <> ' '
group by IDnum having count(IDnum)>1 )a
(
select IDnum ,count(*) as n17 from employer where IDnum <> ' '
group by IDnum having count(*)>1 order by IDnum compute sum(count(*))
) a
group by a.n17
datatable dt= new DataTable()
SqlDataAdapter sda = new SqlDataAdapter(sqlString,con);
sda.Fill(dt);
int a= System.Convert.ToInt16(dt.Rows[i]["n17"].ToString());