学生信息表,如下:
         ID       SEX      SCORE    YEAR
         1 男 88 2007
2 女 87 2008
3 男 89 2006
4 女 99 2009
5 男 54 2007
6 女 56 2008要求统计出学生总人数,男生总人数,女生总人数
  小弟是在搞不定,求答案!谢谢

解决方案 »

  1.   

    select count(*) from student;
    select count(*) from student where sex='男';
    select count(*) from student where sex='女';
      

  2.   


    select sex,count(*) from student group by sex
    select count(*) as 总人数 from student很难吗???
      

  3.   


    是采用一条语句展现出上面的统计结果 即: count(*),count(男),count(女) 这样的效果
      

  4.   

    select (select count(*) from student) as total,(select count(*) from student where sex='男') as mens,(select count(*) from student where sex='女') as womens from student;
      

  5.   


    select count(*) 总人数,
    sum(case when sex='男' then 1 else 0 end) 男生人数,
    sum(case when sex='女' then 1 else 0 end) 女生人数
    from student;
      

  6.   


    很对,原来是考察我oracle 函数 
      

  7.   


    这条语句 加上一个distinct 也能行得通