解决方案 »

  1.   

    遍历?直接统计不就好了
    select count(case when order <10 then 1 end) less_10,
    count(case when order >=10 and order<20 then 1 end) between_10_20,
    count(case when order>=20 then 1 end) more_20
    from table;
      

  2.   


    抱歉哈,咱是菜鸟小白。
    我是写在sh文件里面:
    #!/bin/shsqlplus -S /nolog <<EOF
    set heading off feedback off pagesize 0 verify off echo off numwidth 6
    conn comesa/lUft9SkrGb
    select count(case when order <10 then 1 end) less_10,
    count(case when order >=10 and order<20 then 1 end) between_10_20,
    count(case when order>=20 then 1 end) more_20
    from table;
    exit
    EOF不晓得less_10, between_10_20,more_20能不能在 EOF后面shell内使用,还是只能在EOF 之前使用。
    我试试看哈。
    多谢