ps=dbConnection.prepareStatement("SELECT"+"t1.openidasopenId,t1.usernameasuserName,t1.mobileasuserMobile,t1.fkASnormalCard,t2.fkASgroupCard,t1.fk+t2.fkAStotalCard"+"FROM"...
ps=dbConnection.prepareStatement("SELECT "
+ "t1.openid as openId,t1.username as userName,t1.mobile as userMobile,t1.fk AS normalCard,t2.fk AS groupCard,t1.fk + t2.fk AS totalCard"
+ "FROM"
+ "("
+ "SELECT a.openid,a.username,a.usermobile AS mobile, b.fk AS fk FROM"
+ "("
+ "SELECT * FROM t_agent WHERE parentid =?"
+ ")a"
+ "LEFT JOIN ("
+ "SELECT t1.openid,t1.username, t1.usermobile AS mobile,sum(t2.reNum) AS fk"
+ " FROM t_agent t1"
+"INNER JOIN t_recharge t2 ON t2.useropenid = t1.openid"
+" WHERE"
+"t2.createTime >= ?"
+"AND ? >= t2.createTime"
+"AND t1.parentid =?"
+"GROUP BY"
+"t1.openid,"
+"t1.username,"
+"t1.usermobile"
+"ORDER BY"
+"t1.usermobile"
+") b ON a.openid = b.openid"
+ ")t1"
+ "INNER JOIN ("
+ "SELECT a.openid,a.username, a.usermobile AS mobile, b.fk AS fk "
+ " FROM"
+ "("
+ "SELECT * FROM t_agent WHERE parentid =?"
+ ")a"
+ "LEFT JOIN ("
+ "SELECT t1.openid,t1.username, t1.usermobile AS mobile,sum(t2.fk ) AS fk"
+ " FROM t_agent t1"
+ "INNER JOIN t_fklog t2 ON t1.openid = t2.openid"
+ " WHERE t2.createTime >=?"
+ "AND ? >=t2.createTime "
+ "AND t1.parentId =?"
+ "GROUP BY "
+ "t1.openid,"
+ "t1.username,"
+ "t1.usermobile"
+ " ORDER BY"
+ "t1.usermobile"
+ ") b ON a.openid = b.openid"
+ ") t2 ON t1.openid = t2.openid"
+ " ORDER BY"
+ "totalCard DESC");
展开