56,677
社区成员
发帖
与我相关
我的任务
分享
select sum(amount) from consume_log where (type =2001 or type=1001) and recordtime <1212163200 and recordtime>=1209571200
ResultSet rs = con.executeQuery(); //就上面那条SQL语句拿来查
int type = 0;
while (rs.next()) {
type = getType(Math.abs(rs.getInt("total")), sect); //getType方法用来区分用户属于哪个档次的消费用户
totalAmount += Math.abs(rs.getInt("total")); //totalAmount,totalPersons是两个全局的变量,用来记录消费总额,和总人数,最后两者相除可以得到一个平均数.
totalPersons++;
if (map.containsKey(type)) {
map.put(type, map.get(type) + 1);
} else {
map.put(type, 1);
}
}
CREATE TABLE aa(account int(10),
memberid int(10),
addtime int(10)
)
partition by list(memberid)
(
partition p0 values in(1),
partition p1 values in(2),
partition p2 values in(3),
partition p3 values in(4),
partition p4 values in(5),
partition p5 values in(6),
partition p6 values in(7),
partition p7 values in(8),
partition p8 values in(9),
partition p9 values in(10)
);