SQL

select count(distinct IDnum ) as n17,count(IDnum) from employer where IDnum <> ' '
group by IDnum having count(IDnum)>1 --在查询分析询里显示的记录数

解决方案 »

  1.   

    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
      

  2.   

    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
      

  3.   

    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());