建立表temp,结构为name,number
  每次清空后利用select 语句添加进去,再显示表即可以

解决方案 »

  1.   

    select count(*) as 总计 from 人才表select count(*) as 本科 from 人才表 where 学历 like '本科'select count(*) as 专科 from 人才表 where 学历 like '专科'select count(*) as 中专 from 人才表 where 学历 like '中专'select count(*) as 硕士 from 人才表 where 学历 like '硕士'
      

  2.   

    select 学历,count(学历) from syspwd group by 学历
      

  3.   

    select 人名,性别,年龄 count(case when 学历='本科' then 1 end) '本科',count(case when 学历='专科' then 1 end) '专科',count(case when 学历='中专' then 1 end) '中专',count(case when 学历='硕士'then 1 end) '硕士',count(*) '总人数' ,籍贯 from  人才表
      

  4.   

    select count(*) as 总计 from 人才表         --这个是求总数的,你单独放开!!将如下查询一并运行;select 学历='本科',count(*) as 总计 from 人才表 where 学历 like '本科'
    union
    select 学历='专科',count(*) as 总计 from 人才表 where 学历 like '专科'
    union
    select 学历='中专',count(*) as 总计 from 人才表 where 学历 like '中专'
    union
    select 学历='硕士',count(*) as 总计 from 人才表 where 学历 like '硕士'将得到一个表,内容格式为:学历       |     总计
    本科       |   xxx
    专科       |  xxx
    ..............
    ..
    ..
      

  5.   

    大家误会了。
    在这个时候具体的学历是很多的,是有变化的。
    所以在查询语句中,不能出现本科,专科……字样的。
    但是查询以后,会显示在dbgrid中。
      

  6.   

    select 学历,count(学历) from syspwd group by 学历 回复人: goodhazel(小猪 的试试。
      

  7.   

    select count(*) as 总计 from 人才表
      

  8.   

    如果列是变化的,一个SQL是些不出来的。
    一个办法是需要写存储过程来统计,另一个办法是在程序中根据学历种类的个数动态拼楼上写的那些SQL.