我要统计name1列和name2列,sql语句怎么写?

解决方案 »

  1.   

    select count(name1),count(name2) from your_table;
    通过这样计算,不会计算你字段为null的
      

  2.   


    我想要这样的select name1,count(name1),name2,count(name2) from test.....
      

  3.   

    select name1,total1,name2,total2 from
    (
    select name1,count(name1) total1 from test group by name1
    )
    ,
    (select name2,count(name2) total2 from test group by name2
    );
      

  4.   


    select name1,total1,name2,total2 from
    (
    select name1,count( distinct name1) total1 from test group by name1
    )
    ,
    (select name2,count( distinct name2) total2 from test group by name2
    );
      

  5.   

    select name1,count(name1)over(partition by name1 ),name2,count(name2)over(partition by name2) from test.....