解决方案 »

  1.   

    我的方法比较笨,先用case when 语句来逐个的求出各个字符中on的个数。然后。再插入到一个表中,最后用max函数
      

  2.   

    with a as(
    select 'BXZS'col_name,sum(case when bxzs='on' then 1 end) num from biao
    union all
    select 'XTJS',sum(case when xtjs='on' then 1 end) num from biao)--获得结果集
    select col_name from a where num=(select max(num) from a)
      

  3.   


    select case
             when c1 > c2 then
              'col1'
             else
              'col2'
           end column_name
      from (select sum(case
                         when col1 = 'on' then
                          1
                         else
                          0
                       end) c1,
                   sum(case
                         when col2 = 'on' then
                          1
                         else
                          0
                       end) c2
              from table_name)
      

  4.   

    可以分别查询两个字段=0n的数量,然后比较。此方法仅仅先on的字段比较少!
      

  5.   

    我是在java中判断的,取出出现最多次数为多少次,然后取出出现最多次数的数据保存在数组中。