--测量次数为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
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方法跟着差不多,换一下数组就可以了
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
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方法跟着差不多,换一下数组就可以了