两个办法,一是建立一个整型数组,把几个值用循环分别放进去。
这个方法要注意循环一次之后用break跳出来,否则会把所有的重写一次。
二就方便了,接到数值之后,可以把数值放在Vector数组里,后面接出来就可以了。

解决方案 »

  1.   

    --测量次数为3是否包括测试次数为2和为1中,如果不包括:
    select 
        燃料    = rlzl,
        测量1次 = sum(case clcs when 1 then 1 else 0 end),
        测量2次 = sum(case clcs when 2 then 1 else 0 end),
        测量3次 = sum(case clcs when 3 then 1 else 0 end),
        测量4次 = sum(case clcs when 4 then 1 else 0 end),
        测量5次 = sum(case clcs when 5 then 1 else 0 end)
    from 
        cardata_doc 
    where 
        rlzl='B' 
    group by rlzl--否则:
    select 
        燃料    = rlzl,
        测量1次 = sum(case when clcs>0 then 1 else 0 end),
        测量2次 = sum(case when clcs>1 then 1 else 0 end),
        测量3次 = sum(case when clcs>2 then 1 else 0 end),
        测量4次 = sum(case when clcs>3 then 1 else 0 end),
        测量5次 = sum(case when clcs>4 then 1 else 0 end)
    from 
        cardata_doc 
    where 
        rlzl='B' 
    group by rlzl
      

  2.   

    sql="select count(*) as num from cardata_doc where rlzl='B' group by clcs";
    ResultSet rs = stmt.executeQuery(sql);
    int n[]=new int[5];
    for(int i=0;i<5;i++){
    if(rs.next()){
    n[i]=rs.getInt("num");
    break;}
    }
    这样可以把count(*)的数值放在num里,再取出来放在数组n[5]里使用Vector方法跟着差不多,换一下数组就可以了